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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user