Add a function to perform internal processing of wxSysColourChangedEvent
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxQt (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxX11 (push) Canceled after 0s
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Canceled after 0s
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxDFB (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Canceled after 0s
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Canceled after 0s
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Canceled after 0s
CMake builds / macOS latest wxGTK 3 Unix Makefiles (push) Canceled after 0s
CMake builds / MSW/MSVC wxMSW (push) Canceled after 0s
CMake builds / MSW/Clang wxMSW (push) Canceled after 0s
CMake builds / macOS latest wxOSX Ninja (push) Canceled after 0s
CMake builds / macOS 14 wxOSX Xcode (push) Canceled after 0s
CMake builds / macOS 14 wxIOS (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 5.15 (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 6.10 (push) Canceled after 0s
Mac builds / wxMac ARM ASAN not compatible (push) Canceled after 0s
Mac builds / wxMac Universal C++14 (push) Canceled after 0s
Mac builds / wxiOS Simulator on Silicon Mac (push) Canceled after 0s
Mac builds / wxiOS (push) Canceled after 0s
Mac builds / wxMac Intel C++17 (push) Canceled after 0s
Mac Xcode builds / iOS Simulator static (push) Canceled after 0s
Mac Xcode builds / macOS dynamic Release (push) Canceled after 0s
Mac Xcode builds / iOS static Debug (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Release x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Debug Win32 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Release arm64 (push) Canceled after 0s
MSW builds / wxMSW vs2026 DLL Release x64 (push) Canceled after 0s
MSW cross-builds / wxMSW 64 bits not compatible (push) Canceled after 0s
MSW cross-builds / wxMSW/Univ (push) Canceled after 0s
MSW cross-builds / wxMSW 32 bits (push) Canceled after 0s
Code Checks / Check Spelling (push) Canceled after 0s
Code Checks / Check Whitespace (push) Canceled after 0s
Code Checks / Check Mixed EOL (push) Canceled after 0s
Code Checks / Check C++ Style (push) Canceled after 0s
Code Checks / Check All Headers In allheaders.h (push) Canceled after 0s

This avoids the chronic problem of wxSysColourChangedEvent handlers
inadvertently failing to call Skip() and thus blocking important internal
processing, including propagating to child windows.
This commit is contained in:
Paul Cornett
2026-07-29 10:56:59 -07:00
committed by paulcor
parent 0268bc21d1
commit 74ea434841
15 changed files with 36 additions and 72 deletions
+3 -4
View File
@@ -16,6 +16,7 @@ class WXDLLIMPEXP_FWD_CORE wxTaskBarButton;
class WXDLLIMPEXP_CORE wxFrame : public wxFrameBase
{
typedef wxFrameBase BaseType;
public:
// construction
wxFrame() { Init(); }
@@ -47,9 +48,6 @@ public:
// implementation only from now on
// -------------------------------
// event handlers
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Toolbar
#if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = -1,
@@ -88,6 +86,8 @@ public:
// override the base class function to handle iconized/maximized frames
virtual void SendSizeEvent(int flags = 0) override;
virtual void SendSysColourChangedEvents() override;
virtual wxPoint GetClientAreaOrigin() const override;
// override base class version to add menu bar accel processing
@@ -186,7 +186,6 @@ private:
wxTaskBarButton* m_taskBarButton;
#endif
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFrame);
};
+1 -3
View File
@@ -544,8 +544,7 @@ public:
wxShowEffect effect,
unsigned timeout);
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
virtual void SendSysColourChangedEvents() override;
// initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
@@ -837,7 +836,6 @@ protected:
private:
wxDECLARE_DYNAMIC_CLASS(wxWindowMSW);
wxDECLARE_NO_COPY_CLASS(wxWindowMSW);
wxDECLARE_EVENT_TABLE();
};
// window creation helper class: before creating a new HWND, instantiate an
+3 -1
View File
@@ -18,6 +18,7 @@ class WXDLLIMPEXP_FWD_CORE wxMacToolTip ;
class WXDLLIMPEXP_CORE wxFrame: public wxFrameBase
{
typedef wxFrameBase BaseType;
public:
// construction
wxFrame() = default;
@@ -53,7 +54,6 @@ public:
// event handlers
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Toolbar
#if wxUSE_TOOLBAR
@@ -79,6 +79,8 @@ public:
// internal response to size events
virtual void MacOnInternalSize() override { PositionBars(); }
virtual void SendSysColourChangedEvents() override;
protected:
#if wxUSE_TOOLBAR
virtual void PositionToolBar() override;
+2 -1
View File
@@ -1612,7 +1612,6 @@ public:
static inline const wxWindow* AsWindow(const wxWindowBase* win);
// event handlers
void OnSysColourChanged( wxSysColourChangedEvent& event );
void OnInitDialog( wxInitDialogEvent &event );
void OnMiddleClick( wxMouseEvent& event );
#if wxUSE_HELP
@@ -1627,6 +1626,8 @@ public:
// Returns true if more idle time is requested.
virtual bool SendIdleEvents(wxIdleEvent& event);
virtual void SendSysColourChangedEvents();
// Send wxContextMenuEvent and return true if it was processed.
//
// Note that the event may end up being sent to a different window, if this
+1 -3
View File
@@ -1005,7 +1005,6 @@ void wxPreviewCanvas::OnDPIChanged(wxDPIChangedEvent& event)
event.Skip();
}
// Responds to colour changes, and passes event on to children.
void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event)
{
#ifdef __WXMAC__
@@ -1020,8 +1019,7 @@ void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event)
SetBackgroundColour(wxSystemSettings::GetColour(colourIndex));
Refresh();
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
event.Skip();
}
void wxPreviewCanvas::OnChar(wxKeyEvent &event)
+6 -5
View File
@@ -113,7 +113,6 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler);
// ----------------------------------------------------------------------------
wxBEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindowBase::OnInitDialog)
EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick)
@@ -3019,8 +3018,12 @@ wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) const
// ----------------------------------------------------------------------------
// propagate the colour change event to the subwindows
void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
void wxWindowBase::SendSysColourChangedEvents()
{
wxSysColourChangedEvent event;
event.SetEventObject(this);
HandleWindowEvent(event);
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
@@ -3028,9 +3031,7 @@ void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
wxWindow *win = node->GetData();
if ( !win->IsTopLevel() )
{
wxSysColourChangedEvent event2;
event2.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event2);
win->SendSysColourChangedEvents();
}
node = node->GetNext();
+1 -3
View File
@@ -1612,14 +1612,12 @@ void wxGenericCalendarCtrl::OnYearTextChange(wxCommandEvent& event)
HandleYearChange(event);
}
// Responds to colour changes, and passes event on to children.
void wxGenericCalendarCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// reinit colours
InitColours();
// Propagate the event to the children
wxControl::OnSysColourChanged(event);
event.Skip();
// Redraw control area
SetBackgroundColour(m_colBackground);
+1 -2
View File
@@ -460,8 +460,7 @@ void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event)
{
InitColours();
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
event.Skip();
}
#ifdef __WXGTK__
+1 -3
View File
@@ -328,9 +328,7 @@ void DoUpdateColorScheme(wxGTKImpl::ColorScheme colorScheme)
for (auto* win: wxTopLevelWindows)
{
wxSysColourChangedEvent event;
event.SetEventObject(win);
win->HandleWindowEvent(event);
win->SendSysColourChangedEvents();
}
}
+1 -3
View File
@@ -564,9 +564,7 @@ gtk_frame_window_state_callback( GtkWidget* WXUNUSED(widget),
extern "C" {
static void notify_gtk_theme_name(GObject*, GParamSpec*, wxTopLevelWindowGTK* win)
{
wxSysColourChangedEvent event;
event.SetEventObject(win);
win->HandleWindowEvent(event);
win->SendSysColourChangedEvents();
}
}
+2 -11
View File
@@ -66,14 +66,6 @@
extern wxMenu *wxCurrentPopupMenu;
#endif // wxUSE_MENUS || wxUSE_MENUS_NATIVE
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
wxBEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
wxEND_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
@@ -470,7 +462,7 @@ wxTaskBarButton* wxFrame::MSWGetTaskBarButton()
}
#endif // wxUSE_TASKBARBUTTON
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
void wxFrame::SendSysColourChangedEvents()
{
#if wxUSE_MENUS && wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
if ( wxMenuBar* const menuBar = GetMenuBar() )
@@ -479,8 +471,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
}
#endif // wxUSE_MENUS && wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
// Let children react to this event too.
event.Skip();
BaseType::SendSysColourChangedEvents();
}
// Pass true to show full screen, false to restore.
+8 -15
View File
@@ -299,20 +299,12 @@ static bool wxIsTouchEventMSW()
return (::GetMessageExtraInfo() & SIGNATURE_MASK) == MI_WP_SIGNATURE;
}
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------
// in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu()
// method
#ifdef __WXUNIVERSAL__
wxIMPLEMENT_ABSTRACT_CLASS(wxWindowMSW, wxWindowBase);
#endif // __WXUNIVERSAL__
wxBEGIN_EVENT_TABLE(wxWindowMSW, wxWindowBase)
EVT_SYS_COLOUR_CHANGED(wxWindowMSW::OnSysColourChanged)
wxEND_EVENT_TABLE()
// ===========================================================================
// implementation
// ===========================================================================
@@ -4829,7 +4821,6 @@ wxWindowMSW::MSWOnDrawItem(int WXUNUSED_UNLESS_ODRAWN(id),
{
return item->MSWOnDraw(itemStruct);
}
#endif // wxUSE_CONTROLS
return false;
@@ -5090,10 +5081,7 @@ bool wxWindowMSW::HandleSysColorChange()
// that information.
wxMSWDarkMode::NotifySysColorChange();
wxSysColourChangedEvent event;
event.SetEventObject(this);
(void)HandleWindowEvent(event);
SendSysColourChangedEvents();
if ( IsTopLevel() )
Refresh();
@@ -5271,8 +5259,7 @@ bool wxWindowMSW::HandleQueryNewPalette()
return HandleWindowEvent(event) && event.GetPaletteRealized();
}
// Responds to colour changes: passes event on to children.
void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
void wxWindowMSW::SendSysColourChangedEvents()
{
// the top level window also reset the standard colour map as it might have
// changed (there is no need to do it for the non top level windows as we
@@ -5290,6 +5277,10 @@ void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
MSWSetDarkOrLightMode(SetMode::Change);
}
wxSysColourChangedEvent event;
event.SetEventObject(this);
ProcessWindowEvent(event);
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
@@ -5306,6 +5297,8 @@ void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
node = node->GetNext();
}
// Base class functionality is duplicated here, so don't chain up
}
extern wxCOLORMAP *wxGetStdColourMap()
+3 -9
View File
@@ -43,7 +43,6 @@ int GetMacStatusbarHeight()
wxBEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
EVT_ACTIVATE(wxFrame::OnActivate)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
wxEND_EVENT_TABLE()
// ----------------------------------------------------------------------------
@@ -179,23 +178,18 @@ void wxFrame::PositionStatusBar()
}
#endif // wxUSE_STATUSBAR
// Responds to colour changes, and passes event on to children.
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
void wxFrame::SendSysColourChangedEvents()
{
Refresh();
#if wxUSE_STATUSBAR
if ( m_frameStatusBar )
{
wxSysColourChangedEvent event2;
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
m_frameStatusBar->SendSysColourChangedEvents();
}
#endif // wxUSE_STATUSBAR
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
BaseType::SendSysColourChangedEvents();
}
// Default activation behaviour - set the focus for the first child
+1 -3
View File
@@ -238,13 +238,11 @@ void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
event.Skip();
}
// Responds to colour changes, and passes event on to children.
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO
// Propagate the event to the non-top-level children
wxFrame::OnSysColourChanged(event);
event.Skip();
}
bool wxMDIParentFrame::ShouldBeVisible() const
+2 -6
View File
@@ -702,9 +702,7 @@ static void SendFullScreenWindowEvent(NSNotification* notification, bool fullscr
objectForKey:@"NSBackingPropertyOldColorSpaceKey"];
if (![newColorSpace isEqual:oldColorSpace])
{
wxSysColourChangedEvent event;
event.SetEventObject(wxpeer);
wxpeer->HandleWindowEvent(event);
wxpeer->SendSysColourChangedEvents();
}
}
}
@@ -731,9 +729,7 @@ static void SendFullScreenWindowEvent(NSNotification* notification, bool fullscr
wxNonOwnedWindow* wxpeer = windowimpl ? windowimpl->GetWXPeer() : nullptr;
if (wxpeer)
{
wxSysColourChangedEvent event;
event.SetEventObject(wxpeer);
wxpeer->HandleWindowEvent(event);
wxpeer->SendSysColourChangedEvents();
}
}
}