Pending events unexpectedly dispatched from wxGenericProgressDialog::Update() in wxGTK and MSW
|Reported by:||hagen||Owned by:|
|Keywords:||wxGenericProgressDialog wxGUIEventLoop YieldFor regression||Cc:|
I am using wxGTK v3.0.0 on a Ubuntu 13.10 system.
My application uses a wxThread to implement a background job. This thread produces two types of events,
- Progress event (wxCommandEvent)
- Finished event (wxCommandEvent)
These events are handled in the main thread doing the following:
- The progress event updates a wxProgressDialog using wxGenericProgressDialog::Update
- The finished event destroys the wxProgressDialog
All progress events are generated consecutively and are followed by one finished event. Thus I expect all progress events are completely handled before the finished event is handled.
Instead what I see is that the finished event is somehow processed before the last progress event is completely handled. This results in segmentation fault since the progress dialog is destroyed before the last progress event is completely handled.
The source of the problem is the call to wxProgressDialog::update which in turn calls wxGenericProgressDialog::DoBeforeUpdate which in turn calls wxGUIEventLoop::YieldFor. In wxGenericProgressDialog (line 543) it is pointed out that the call to YieldFor should only process wxEVT_CATEGORY_UI and wxEVT_CATEGORY_USER_INPUT events.
But within gtk/wxGUIEventLoop::YieldFor (line 399) the following is called: wxTheApp->ProcessPendingEvents(). This leads to the processing of all events regardless of their specific type (including my finished event).
I dug a little deeper into the problem. The last change to gtk/wxGUIEventLoop.cpp was done by Rob Bresalier between wxWidgets v2.9.4 and v2.9.5. So I compiled my application against wxWidgets v2.9.4 and v2.9.5 with the follwing result,
- wxWidgets v2.9.4: my application runs without problems
- wxWidgets v2.9.5: my application crashes due to the described problem
The diff of the two versions (2.9.4 and 2.9.5) of gtk/wxGUIEventLoop.cpp revealed that among other things the line wxTheApp->ProcessPendingEvents() (line 398/399) was added. This line in fact leads to the described problem.
At this point I can not give further information or point out a good solution to this problem due to my lack of knowledge in gtk.
Again the problem is only existing in wxGTK. I did not encounter he problem in wxMSW. I did not check against cocoa.
Change History (9)
comment:1 Changed 13 months ago by vadz
- Keywords regression added
- Status changed from new to confirmed
- Summary changed from wrong event processing in wxGenericProgressDialog::Update / wxGUIEventLoop::YieldFor to Pending events unexpectedly dispatched from wxGenericProgressDialog::Update() in wxGTK
comment:5 Changed 11 months ago by vadz
- Milestone set to 3.0.2
- Resolution set to port to stable
- Status changed from confirmed to portneeded
comment:7 Changed 7 months ago by hagen
- Summary changed from Pending events unexpectedly dispatched from wxGenericProgressDialog::Update() in wxGTK to Pending events unexpectedly dispatched from wxGenericProgressDialog::Update() in wxGTK and MSW