diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 5b681f2a539e..bc20cbe7550b 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1192,9 +1192,11 @@ protected: * the preferred widget size. * * Use get_preferred_size to retrieve this value - * mediated via height and width requests + * cached and mediated via height and width requests */ virtual Size GetOptimalSize() const; + /// clear OptimalSize cache + void InvalidateSizeCache(); private: SAL_DLLPRIVATE bool ImplIsAccessibleCandidate() const; diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx index 21fcc2d401c3..829fd3b8afad 100644 --- a/svx/source/sidebar/PanelLayout.cxx +++ b/svx/source/sidebar/PanelLayout.cxx @@ -51,6 +51,7 @@ void PanelLayout::queue_resize(StateChangedType /*eReason*/) return; if (!isLayoutEnabled(this)) return; + InvalidateSizeCache(); m_aPanelLayoutIdle.Start(); } diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index 5a0df3cbaa46..94e32d34abf5 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -1114,9 +1114,7 @@ void DockingWindow::queue_resize(StateChangedType /*eReason*/) return; if (!isLayoutEnabled()) return; - WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; - pWindowImpl->mnOptimalWidthCache = -1; - pWindowImpl->mnOptimalHeightCache = -1; + InvalidateSizeCache(); maLayoutIdle.Start(); } diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 1455c3b93e2a..c5d0522dc0e1 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -997,9 +997,7 @@ void SystemWindow::queue_resize(StateChangedType /*eReason*/) return; if (!isLayoutEnabled()) return; - WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; - pWindowImpl->mnOptimalWidthCache = -1; - pWindowImpl->mnOptimalHeightCache = -1; + InvalidateSizeCache(); maLayoutIdle.Start(); } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 691b92cd2ebc..e6672875f7c4 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1427,16 +1427,23 @@ namespace } } +void Window::InvalidateSizeCache() +{ + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + pWindowImpl->mnOptimalWidthCache = -1; + pWindowImpl->mnOptimalHeightCache = -1; +} + void Window::queue_resize(StateChangedType eReason) { bool bSomeoneCares = queue_ungrouped_resize(this); - WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; if (eReason != StateChangedType::VISIBLE) { - pWindowImpl->mnOptimalWidthCache = -1; - pWindowImpl->mnOptimalHeightCache = -1; + InvalidateSizeCache(); } + + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VCL_SIZE_GROUP_NONE) { std::set &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();