From cdc588e4eb724c242cce83ce90d4812478528262 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 6 Nov 2019 15:06:36 +0100 Subject: [PATCH] Don't resize the parent from wxToolBar::SetSize() in wxUniv This could result in infinite recursion in wxX11, as the test for the new size being different from the old one which was supposed to stop the recursion, failed there in case the new size was 0: as wxX11 can't use 0 size for the window, the actual size was always different and so we kept sending size events to the parent, which kept resizing the toolbar etc. It could be argued that there is a bug in wxX11 and that GetSize() must return the same value as was passed to SetSize(), even if it was 0, and this might even be correct, in theory, but it doesn't seem worth to do it just to accommodate this weird use case, especially because resizing the parent from the child shouldn't be necessary in the first place and none of wxToolBar implementations in the other ports does it. So just remove this code completely. Closes #18554. --- include/wx/univ/toolbar.h | 3 --- src/univ/toolbar.cpp | 27 --------------------------- 2 files changed, 30 deletions(-) diff --git a/include/wx/univ/toolbar.h b/include/wx/univ/toolbar.h index 7ab15e4bb8..b393311e60 100644 --- a/include/wx/univ/toolbar.h +++ b/include/wx/univ/toolbar.h @@ -101,9 +101,6 @@ protected: const wxString& label) wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE; - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE; // get the bounding rect for the given tool diff --git a/src/univ/toolbar.cpp b/src/univ/toolbar.cpp index 833bd80334..2c2ceffd6c 100644 --- a/src/univ/toolbar.cpp +++ b/src/univ/toolbar.cpp @@ -563,33 +563,6 @@ wxSize wxToolBar::DoGetBestClientSize() const return wxSize(m_maxWidth, m_maxHeight); } -void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags) -{ - int old_width, old_height; - GetSize(&old_width, &old_height); - - wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags); - - // Correct width and height if needed. - if ( width == wxDefaultCoord || height == wxDefaultCoord ) - { - int tmp_width, tmp_height; - GetSize(&tmp_width, &tmp_height); - - if ( width == wxDefaultCoord ) - width = tmp_width; - if ( height == wxDefaultCoord ) - height = tmp_height; - } - - // We must refresh the frame size when the toolbar changes size - // otherwise the toolbar can be shown incorrectly - if ( old_width != width || old_height != height ) - { - SendSizeEventToParent(); - } -} - // ---------------------------------------------------------------------------- // wxToolBar drawing // ----------------------------------------------------------------------------