Remove wxTimerEvent default constructor

This ctor just created unusable wxTimerEvent objects (all of the methods
specific to this class would just crash if called on them) and doesn't
seem to be useful at all.

It was added in e47859daeb apparently only
in order to allow using wxIMPLEMENT_DYNAMIC_CLASS() instead of the
previously used wxIMPLEMENT_ABSTRACT_CLASS() for wxTimerEvent, but there
doesn't seem to be any reason to prefer macro over another, and there
are good reasons to not allow creating objects in an invalid state.

The only place where we relied on having default ctor for this event was
in wxEvent::Clone() unit test, so update it to handle wxTimerEvent
specially now that this ctor doesn't exist any longer.
This commit is contained in:
Vadim Zeitlin
2019-07-12 16:10:26 +02:00
parent 914e6f99f4
commit bd09b4132d
3 changed files with 29 additions and 16 deletions

View File

@@ -159,26 +159,23 @@ private:
class WXDLLIMPEXP_BASE wxTimerEvent : public wxEvent
{
public:
wxTimerEvent()
: wxEvent(wxID_ANY, wxEVT_TIMER) { m_timer=NULL; }
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; }
private:
wxTimer* m_timer;
wxTimer& m_timer;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTimerEvent);
};