Don't allow drawing to a zero-height or zero-width GAL canvas.

Fixes: lp:1793913
* https://bugs.launchpad.net/kicad/+bug/1793913

(cherry picked from commit 0309228276)
This commit is contained in:
Jeff Young 2018-09-22 22:01:47 +01:00
parent 4fcd80eda1
commit 1820e81f5e
4 changed files with 13 additions and 8 deletions

View File

@ -147,6 +147,12 @@ void EDA_DRAW_PANEL_GAL::SetFocus()
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
{ {
m_viewControls->UpdateScrollbars();
// Drawing to a zero-width or zero-height GAL is fraught with peril.
if( GetClientRect().IsEmpty() )
return;
m_pendingRefresh = false; m_pendingRefresh = false;
if( m_drawing ) if( m_drawing )
@ -161,8 +167,6 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_drawing = true; m_drawing = true;
KIGFX::RENDER_SETTINGS* settings = static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() ); KIGFX::RENDER_SETTINGS* settings = static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() );
m_viewControls->UpdateScrollbars();
try try
{ {
m_view->UpdateItems(); m_view->UpdateItems();

View File

@ -222,7 +222,7 @@ bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
void OPENGL_GAL::BeginDrawing() void OPENGL_GAL::BeginDrawing()
{ {
if( !IsShownOnScreen() ) if( !IsShownOnScreen() || GetClientRect().IsEmpty() )
return; return;
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@ -393,7 +393,7 @@ void OPENGL_GAL::EndDrawing()
void OPENGL_GAL::BeginUpdate() void OPENGL_GAL::BeginUpdate()
{ {
if( !IsShownOnScreen() ) if( !IsShownOnScreen() || GetClientRect().IsEmpty() )
return; return;
if( !isInitialized ) if( !isInitialized )

View File

@ -88,8 +88,9 @@ public:
virtual ~CAIRO_GAL(); virtual ~CAIRO_GAL();
///> @copydoc GAL::IsVisible() ///> @copydoc GAL::IsVisible()
bool IsVisible() const override { bool IsVisible() const override
return IsShownOnScreen(); {
return IsShownOnScreen() && !GetClientRect().IsEmpty();
} }
// --------------- // ---------------

View File

@ -89,13 +89,13 @@ public:
virtual bool IsInitialized() const override virtual bool IsInitialized() const override
{ {
// is*Initialized flags, but it is enough for OpenGL to show up // is*Initialized flags, but it is enough for OpenGL to show up
return IsShownOnScreen(); return IsShownOnScreen() && !GetClientRect().IsEmpty();
} }
///> @copydoc GAL::IsVisible() ///> @copydoc GAL::IsVisible()
bool IsVisible() const override bool IsVisible() const override
{ {
return IsShownOnScreen(); return IsShownOnScreen() && !GetClientRect().IsEmpty();
} }
// --------------- // ---------------