Gracefully handle parent disappearance in wxGenericProgressDialog
Use a weak reference to the parent instead of a pointer to avoid crashing if the parent TLW is destroyed before wxGenericProgressDialog itself is. This is unlikely to happen in C++ code, where objects of this class are typically created on the stack, but can happen in e.g. wxPython where this is not the case. Closes #16378.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#define __PROGDLGH_G__
|
#define __PROGDLGH_G__
|
||||||
|
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
|
#include "wx/weakref.h"
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxButton;
|
class WXDLLIMPEXP_FWD_CORE wxButton;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxEventLoop;
|
class WXDLLIMPEXP_FWD_CORE wxEventLoop;
|
||||||
@@ -183,8 +184,9 @@ private:
|
|||||||
*m_estimated,
|
*m_estimated,
|
||||||
*m_remaining;
|
*m_remaining;
|
||||||
|
|
||||||
// parent top level window (may be NULL)
|
// Reference to the parent top level window, automatically becomes NULL if
|
||||||
wxWindow *m_parentTop;
|
// it it is destroyed and could be always NULL if it's not given at all.
|
||||||
|
wxWindowRef m_parentTop;
|
||||||
|
|
||||||
// Progress dialog styles: this is not the same as m_windowStyle because
|
// Progress dialog styles: this is not the same as m_windowStyle because
|
||||||
// wxPD_XXX constants clash with the existing TLW styles so to be sure we
|
// wxPD_XXX constants clash with the existing TLW styles so to be sure we
|
||||||
|
Reference in New Issue
Block a user