From 9e2ff111a4f948a92348b91f75687ba3949fb733 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 11 Oct 2019 19:22:55 +0200 Subject: [PATCH] Restore, but deprecate, default ctor of wxTimerEvent Apparently some existing code still used it, even though it only created an object that could never be used for anything, so undo its removal in bd09b4132d708d6c2267d080ed36ca6dd2eab53e and deprecate it instead. Unfortunately, this also requires changing wxTimerEvent::m_timer type back to pointer, even though it should be a reference. --- include/wx/timer.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/wx/timer.h b/include/wx/timer.h index fb15b3551b..42af63d9a9 100644 --- a/include/wx/timer.h +++ b/include/wx/timer.h @@ -161,21 +161,29 @@ class WXDLLIMPEXP_BASE wxTimerEvent : public wxEvent public: wxTimerEvent(wxTimer& timer) : wxEvent(timer.GetId(), wxEVT_TIMER), - m_timer(timer) + m_timer(&timer) { SetEventObject(timer.GetOwner()); } // accessors - int GetInterval() const { return m_timer.GetInterval(); } - wxTimer& GetTimer() const { return m_timer; } + int GetInterval() const { return m_timer->GetInterval(); } + wxTimer& GetTimer() const { return *m_timer; } // implement the base class pure virtual virtual wxEvent *Clone() const wxOVERRIDE { return new wxTimerEvent(*this); } virtual wxEventCategory GetEventCategory() const wxOVERRIDE { return wxEVT_CATEGORY_TIMER; } + // default ctor creates an unusable event object and should not be used (in + // fact, no code outside wxWidgets is supposed to create event objects) +#if WXWIN_COMPATIBILITY_3_0 + wxDEPRECATED_MSG("wxTimerEvent not supposed to be created by user code") + wxTimerEvent() + : wxEvent(wxID_ANY, wxEVT_TIMER) { m_timer=NULL; } +#endif // WXWIN_COMPATIBILITY_3_0 + private: - wxTimer& m_timer; + wxTimer* m_timer; wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTimerEvent); };