Opened 8 years ago

Closed 8 years ago

#11458 closed defect (fixed)

BUG in wxWindowBase::OnSysColourChanged(), trunk

Reported by: andim2 Owned by:
Priority: normal Milestone:
Component: wxUniv (any port) Version:
Keywords: wxSysColourChangedEvent OnSysColourChanged SetEventObject GetEventObject Cc:
Blocked By: Blocking:
Patch: no



[caught by an ASSERT in my app, using 2.8.10]

2464 propagate the colour change event to the subwindows
2465 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
2466 {
2467 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
2468 while ( node )
2469 {
Only propagate to non-top-level windows
2471 wxWindow *win = node->GetData();
2472 if ( !win->IsTopLevel() )
2473 {
2474 wxSysColourChangedEvent event2;
2475 event.SetEventObject(win);
2476 win->GetEventHandler()->ProcessEvent(event2);
2477 }
2479 node = node->GetNext();
2480 }
2482 Refresh();
2483 }

Million dollar question: what's wrong?

Yup, event <--> event2.

Maybe this even warrants cooking up a semantic patch to check against other
such inconvenient mismatches in this highly prominent triple-sequence of event
handling in all other places...

Andreas Mohr

Change History (3)

comment:1 follow-up: Changed 8 years ago by andim2

Side note: with a const-reference signature of this handler, the bug would have been stopped cold in its tracks...

comment:2 in reply to: ↑ 1 Changed 8 years ago by vadz

  • Priority changed from high to normal
  • Status changed from new to confirmed

Replying to andim2:

Side note: with a const-reference signature of this handler, the bug would have been stopped cold in its tracks...

It would also make it impossible to call event.Skip() or event.Veto()...

OTOH not making SetEventObject() public (but requiring to pass it in the ctor because all events must have it) would have made it impossible. Unfortunately it's impossible to do this now.

comment:3 Changed 8 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [62818]) Fix event object in wxSysColourChangedEvent.

The handler for this event in the base class incorrectly changed the event
object of the original event instead of setting it for the event being sent to
the window children as it was supposed to.

Closes #11458.

Note: See TracTickets for help on using tickets.