From 66c5762ab90c6b1d278206c2539690dd1aaef29d Mon Sep 17 00:00:00 2001 From: sbrowne Date: Sun, 16 Jul 2017 02:22:46 +0200 Subject: [PATCH] Fix check for unchanged size in MSW wxWindow::DoSetSize() Adjust the size and position we're about to set before comparing them with the current ones, otherwise the result of the comparison could be wrong when width and/or height are -1. See #17075. --- src/msw/window.cpp | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index da1cd7839b..c5922d84a1 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1877,35 +1877,11 @@ void wxWindowMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags) GetPosition(¤tX, ¤tY); GetSize(¤tW, ¤tH); - // ... and don't do anything (avoiding flicker) if it's already ok unless - // we're forced to resize the window - if ( !(sizeFlags & wxSIZE_FORCE) ) - { - if ( width == currentW && height == currentH ) - { - // We need to send wxSizeEvent ourselves because Windows won't do - // it if the size doesn't change. - if ( sizeFlags & wxSIZE_FORCE_EVENT ) - { - wxSizeEvent event( wxSize(width,height), GetId() ); - event.SetEventObject( this ); - HandleWindowEvent( event ); - } - - // Still call DoMoveWindow() below if we need to change the - // position, otherwise we're done. - if ( x == currentX && y == currentY ) - return; - } - } - if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) x = currentX; if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) y = currentY; - AdjustForParentClientOrigin(x, y, sizeFlags); - wxSize size = wxDefaultSize; if ( width == wxDefaultCoord ) { @@ -1940,6 +1916,30 @@ void wxWindowMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags) } } + // ... and don't do anything (avoiding flicker) if it's already ok unless + // we're forced to resize the window + if ( !(sizeFlags & wxSIZE_FORCE) ) + { + if ( width == currentW && height == currentH ) + { + // We need to send wxSizeEvent ourselves because Windows won't do + // it if the size doesn't change. + if ( sizeFlags & wxSIZE_FORCE_EVENT ) + { + wxSizeEvent event( wxSize(width,height), GetId() ); + event.SetEventObject( this ); + HandleWindowEvent( event ); + } + + // Still call DoMoveWindow() below if we need to change the + // position, otherwise we're done. + if ( x == currentX && y == currentY ) + return; + } + } + + AdjustForParentClientOrigin(x, y, sizeFlags); + DoMoveWindow(x, y, width, height); }