Ticket #15642 (closed defect: fixed)
wxPropertyGrid::OnSysColourChanged leads to access violation
|Reported by:||hajokirchhoff||Owned by:|
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:
1. wxPropertyGrid::Create() creates the window.
2. A WM_SYSCOLOR_CHANGE event is received and
3. OnSysColourChanged() calls RegainColours(), which
4. tries to store the color in m_categoryDefaultCell
5. 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.