wxTimer::Start() only works from the main thread: mention it in the docs and add an assert in the code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,8 @@ In any case, you must start the timer with \helpref{Start}{wxtimerstart}
|
||||
after constructing it before it actually starts sending notifications. It can
|
||||
be stopped later with \helpref{Stop}{wxtimerstop}.
|
||||
|
||||
{\bf NB:} note that timer can only be used from the main thread currently.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
\helpref{wxObject}{wxobject}
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/thread.h"
|
||||
#endif
|
||||
|
||||
#include "wx/timer.h"
|
||||
@@ -131,6 +132,13 @@ void wxTimerBase::Notify()
|
||||
|
||||
bool wxTimerBase::Start(int milliseconds, bool oneShot)
|
||||
{
|
||||
// under MSW timers only work when they're started from the main thread so
|
||||
// let the caller know about it
|
||||
#ifdef wxUSE_THREADS
|
||||
wxASSERT_MSG( wxThread::IsMain(),
|
||||
_T("timer can only be started from the main thread") );
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
if ( IsRunning() )
|
||||
{
|
||||
// not stopping the already running timer might work for some
|
||||
|
Reference in New Issue
Block a user