diff --git a/src/gtk/timer.cpp b/src/gtk/timer.cpp index a8514f8cd1..721b0f6c0b 100644 --- a/src/gtk/timer.cpp +++ b/src/gtk/timer.cpp @@ -30,9 +30,17 @@ extern "C" gint timeout_callback( gpointer data ) { wxTimer *timer = (wxTimer*)data; - /* when getting called from GDK's timer handler we - are no longer within GDK's grab on the GUI - thread so we must lock it here ourselves */ + // Don't change the order of anything in this callback! + + if ( timer->IsOneShot() ) + { + // This sets m_tag to -1 + timer->Stop(); + } + + // when getting called from GDK's timer handler we + // are no longer within GDK's grab on the GUI + // thread so we must lock it here ourselves gdk_threads_enter(); timer->Notify(); @@ -40,7 +48,7 @@ extern "C" gint timeout_callback( gpointer data ) /* release lock again */ gdk_threads_leave(); - if ( timer->IsOneShot() ) + if (timer->IsOneShot()) return FALSE; return TRUE; diff --git a/src/gtk1/timer.cpp b/src/gtk1/timer.cpp index a8514f8cd1..721b0f6c0b 100644 --- a/src/gtk1/timer.cpp +++ b/src/gtk1/timer.cpp @@ -30,9 +30,17 @@ extern "C" gint timeout_callback( gpointer data ) { wxTimer *timer = (wxTimer*)data; - /* when getting called from GDK's timer handler we - are no longer within GDK's grab on the GUI - thread so we must lock it here ourselves */ + // Don't change the order of anything in this callback! + + if ( timer->IsOneShot() ) + { + // This sets m_tag to -1 + timer->Stop(); + } + + // when getting called from GDK's timer handler we + // are no longer within GDK's grab on the GUI + // thread so we must lock it here ourselves gdk_threads_enter(); timer->Notify(); @@ -40,7 +48,7 @@ extern "C" gint timeout_callback( gpointer data ) /* release lock again */ gdk_threads_leave(); - if ( timer->IsOneShot() ) + if (timer->IsOneShot()) return FALSE; return TRUE;