Opened 8 years ago

Closed 8 years ago

#11525 closed defect (fixed)

Crash when closing App : RemovePendingEventHandler

Reported by: jds210 Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 2.9.0
Keywords: wxEvtHandler destructor Cc:
Blocked By: Blocking:
Patch: yes


When closing an App, the wxApp instance is destroyed, but the destructor of wxEvtHandler (base class) may call RemovePendingEventHandler without checking if it is 'this'. 

If the wxEvtHandler is the App, then errors occur because members of the wxApp object have already been destroyed (notably the critical section objects). Maybe wxEvtHandler should not call RemovePendingEventHandler if the wxTheApp == this?

Attachments (1)

Patch_wxWidgets_2.9.0_event.patch download (422 bytes) - added by jds210 8 years ago.
Proposed patch fixing #11525

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by jds210

Proposed patch fixing #11525

comment:1 Changed 8 years ago by vadz

I think this

  • src/common/appbase.cpp

    diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp
    index c8ec12a..f2bed9a 100644
    a b wxAppConsoleBase::wxAppConsoleBase() 
     157    // we're being destroyed and using this object from now on may not work or
     158    // even crash so don't leave dangling pointers to it
     159    ms_appInstance = NULL;
    157161    delete m_traits;

would be a better fix: if wxTheApp is non-NULL it should be valid.

Could you please test if it fixes your problem?


comment:2 Changed 8 years ago by jds210

Your patch fixes it - Thanks.

comment:3 Changed 8 years ago by VZ

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

(In [62813]) Reset wxTheApp when starting to destroy the object it points to.

Using wxTheApp when the corresponding object is already half destroyed can't
be a good idea so reset it to NULL as soon as possible.

Closes #11525.

Note: See TracTickets for help on using tickets.