From 61c28b35e1470bfde014cdd8bf16a409bd17d018 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 20 Feb 2023 16:55:04 +0000 Subject: [PATCH] Apply workaround to all sibling children, not just the first one This is important as while giving debug message is optional (and might even be not ideal, see the grandparent commit description), we do need to call MSWDisableComposited() when all sibling children already exist as otherwise it wouldn't reset WS_EX_COMPOSITED for them -- and many windows, such as wxOwnerDrawnComboBox are not drawn correctly if they have WS_EX_COMPOSITED and overlap a sibling window (worse, this somehow seems to break the redrawing of the entire TLW, with even the controls completely outside of the static box being affected, see #23239). This commit is best viewed ignoring whitespace-only changes. --- src/common/sizer.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index d51923da24..975c29b801 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -2832,23 +2832,21 @@ bool wxStaticBoxSizer::CheckIfNonBoxChild(wxWindow* win) const wxSizerItem* wxStaticBoxSizer::DoInsert(size_t index, wxSizerItem* item) { - // Check if we have any non-box children unless we already know that we do. - if ( !m_hasNonBoxChildren ) + if ( wxWindow* const win = item->GetWindow() ) { - if ( wxWindow* const win = item->GetWindow() ) - { - // We can check immediately if we have any non-box children and - // it's better to do it here, for example to allow putting a - // breakpoint on wxLogDebug() message above and immediately seeing - // where the item is inserted from, if it's not clear otherwise. - m_hasNonBoxChildren = CheckIfNonBoxChild(win); - } - else if ( item->IsSizer() ) - { - // We can't check immediately as elements can be added to the child - // sizer after adding it to this one, so schedule a check for later. + // We can check immediately if we have any non-box children and + // it's better to do it here, for example to allow putting a + // breakpoint on wxLogDebug() message above and immediately seeing + // where the item is inserted from, if it's not clear otherwise. + if ( CheckIfNonBoxChild(win) ) + m_hasNonBoxChildren = 1; + } + else if ( item->IsSizer() ) + { + // We can't check immediately as elements can be added to the child + // sizer after adding it to this one, so schedule a check for later. + if ( !m_hasNonBoxChildren ) m_hasNonBoxChildren = -1; - } } return wxBoxSizer::DoInsert(index, item);