wxPropertyGrid::OnSysColourChanged leads to access violation
|Reported by:||hajokirchhoff||Owned by:||RD|
A rare occurrence under normal circumstances, but if a WM_SYSCOLOR_CHANGE event is fired during the construction of a wxPropertyGrid, the code will cause an access violation.
Here are the details: We are using a skinning engine that sends a WM_SYSCOLOR_CHANGE event to every window immediately after it is created. wxPropertyGrid::OnSysColorChanged() calls "RegainColours", which in turn tries to access m_categoryDefaultCell. This variable is not initialised until after a call to Init2(), which happens at the end of Create().
Thus, the order of events is this:
- wxPropertyGrid::Create() creates the window.
- A WM_SYSCOLOR_CHANGE event is received and
- OnSysColourChanged() calls RegainColours(), which
- tries to store the color in m_categoryDefaultCell
- which has not yet been initialised because Init2() has not been called.
My proposed fix simply suppresses the WM_SYSCOLOR_CHANGE event until Init2() has been called. This should work fine, since the colours will be initialised in Init2(). IOW, any WM_SYSCOLOR_CHANGE event before this point has no real effect anyway as the colours will be set correctly.