Fix a couple crashes with small canvases
The canvas size is not guaranteed to be strictly > 0, so we need to enforce a minimum returned size before dividing by it or passing to GAL initialization
This commit is contained in:
parent
011e4116d6
commit
12088f240d
|
@ -228,7 +228,9 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
|||
{
|
||||
KIGFX::GAL_CONTEXT_LOCKER locker( m_gal );
|
||||
wxSize clientSize = GetClientSize();
|
||||
m_gal->ResizeScreen( clientSize.x, clientSize.y );
|
||||
clientSize.x = std::max( 10, clientSize.x );
|
||||
clientSize.y = std::max( 10, clientSize.y );
|
||||
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
|
||||
|
||||
if( m_view )
|
||||
{
|
||||
|
@ -414,8 +416,10 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
|||
delete m_gal;
|
||||
m_gal = new_gal;
|
||||
|
||||
wxSize size = GetClientSize();
|
||||
m_gal->ResizeScreen( size.GetX(), size.GetY() );
|
||||
wxSize clientSize = GetClientSize();
|
||||
clientSize.x = std::max( 10, clientSize.x );
|
||||
clientSize.y = std::max( 10, clientSize.y );
|
||||
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
|
||||
|
||||
if( m_painter )
|
||||
m_painter->SetGAL( m_gal );
|
||||
|
|
|
@ -210,6 +210,8 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
{
|
||||
auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
|
||||
auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
|
||||
screenSize.x = std::max( 10.0, screenSize.x );
|
||||
screenSize.y = std::max( 10.0, screenSize.y );
|
||||
double ratio = std::max( fabs( bbSize.x / screenSize.x ),
|
||||
fabs( bbSize.y / screenSize.y ) );
|
||||
|
||||
|
|
|
@ -1081,6 +1081,8 @@ void SELECTION_TOOL::zoomFitSelection()
|
|||
auto view = getView();
|
||||
|
||||
VECTOR2D screenSize = view->ToWorld( m_frame->GetCanvas()->GetClientSize(), false );
|
||||
screenSize.x = std::max( 10.0, screenSize.x );
|
||||
screenSize.y = std::max( 10.0, screenSize.y );
|
||||
|
||||
if( selectionBox.GetWidth() != 0 || selectionBox.GetHeight() != 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue