diff --git a/include/wx/msw/private/timer.h b/include/wx/msw/private/timer.h index 0d7958a316..1e70cd387f 100644 --- a/include/wx/msw/private/timer.h +++ b/include/wx/msw/private/timer.h @@ -19,8 +19,7 @@ class WXDLLIMPEXP_BASE wxMSWTimerImpl : public wxTimerImpl { public: - wxMSWTimerImpl(wxTimer *timer); - virtual ~wxMSWTimerImpl(); + wxMSWTimerImpl(wxTimer *timer) : wxTimerImpl(timer) { m_id = 0; }; virtual bool Start(int milliseconds = -1, bool oneShot = false); virtual void Stop(); diff --git a/src/msw/timer.cpp b/src/msw/timer.cpp index 4193755d71..5f31b15104 100644 --- a/src/msw/timer.cpp +++ b/src/msw/timer.cpp @@ -118,22 +118,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxTimerHiddenWindowModule, wxModule) // wxMSWTimerImpl class // ---------------------------------------------------------------------------- -wxMSWTimerImpl::wxMSWTimerImpl(wxTimer *timer) -:wxTimerImpl(timer) -{ - m_id = GetNewTimerId(this); -} - -wxMSWTimerImpl::~wxMSWTimerImpl() -{ - TimerMap().erase(m_id); -} - bool wxMSWTimerImpl::Start(int milliseconds, bool oneShot) { if ( !wxTimerImpl::Start(milliseconds, oneShot) ) return false; + m_id = GetNewTimerId(this); // SetTimer() normally returns just idTimer but this might change in the // future so use its return value to be safe UINT_PTR ret = ::SetTimer @@ -157,6 +147,8 @@ bool wxMSWTimerImpl::Start(int milliseconds, bool oneShot) void wxMSWTimerImpl::Stop() { ::KillTimer(wxTimerHiddenWindowModule::GetHWND(), m_id); + TimerMap().erase(m_id); + m_id = 0; } // ----------------------------------------------------------------------------