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
bd09b4132d and deprecate it instead.

Unfortunately, this also requires changing wxTimerEvent::m_timer type
back to pointer, even though it should be a reference.
This commit is contained in:
Vadim Zeitlin
2019-10-11 19:22:55 +02:00
parent 92cab3d20a
commit 9e2ff111a4

View File

@@ -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);
};