Opened 4 years ago

Closed 4 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

Description

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 4 years ago.
Proposed patch fixing #11525

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by jds210

Proposed patch fixing #11525

comment:1 Changed 4 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() 
    154154 
    155155wxAppConsoleBase::~wxAppConsoleBase() 
    156156{ 
     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; 
     160 
    157161    delete m_traits; 
    158162} 
    159163 

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

Could you please test if it fixes your problem?

Thanks!

comment:2 Changed 4 years ago by jds210

Your patch fixes it - Thanks.

comment:3 Changed 4 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.