hack to fix wxTimer problem

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8338 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-09-12 13:18:46 +00:00
parent 35fd96a83a
commit e45a8e8b4e
2 changed files with 48 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: gtk/timer.cpp // Name: gtk/timer.cpp
// Purpose: // Purpose: wxTimer implementation
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
// Copyright: (c) 1998 Robert Roebling // Copyright: (c) 1998 Robert Roebling
@@ -16,15 +16,34 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// This is a hack to work around a crash in wxGTK which happens (sometimes)
// when the timer is deleted from the GTK event handler. In this case even
// though the timer is stopped in its dtor, it is apparently too late to
// prevent the dead timer from being called from g_timeout_dispatch() during
// the same iteration of g_main_dispatch(). A better solution must be found,
// possibly by deferring the timer deletion until later, this is only a
// temporary hack! (VZ)
// ----------------------------------------------------------------------------
static wxTimer *gs_timerDead = (wxTimer *)NULL;
// ----------------------------------------------------------------------------
// wxTimer // wxTimer
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject) IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
static gint timeout_callback( gpointer data ) static gint timeout_callback( gpointer data )
{ {
wxTimer *timer = (wxTimer*)data; wxTimer *timer = (wxTimer*)data;
if ( timer == gs_timerDead )
{
// shouldn't be called more than once for the dead timer anyhow
gs_timerDead = NULL;
return FALSE;
}
/* when getting called from GDK's timer handler we /* when getting called from GDK's timer handler we
are no longer within GDK's grab on the GUI are no longer within GDK's grab on the GUI
@@ -50,6 +69,8 @@ void wxTimer::Init()
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
gs_timerDead = this;
wxTimer::Stop(); wxTimer::Stop();
} }

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: gtk/timer.cpp // Name: gtk/timer.cpp
// Purpose: // Purpose: wxTimer implementation
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
// Copyright: (c) 1998 Robert Roebling // Copyright: (c) 1998 Robert Roebling
@@ -16,15 +16,34 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// This is a hack to work around a crash in wxGTK which happens (sometimes)
// when the timer is deleted from the GTK event handler. In this case even
// though the timer is stopped in its dtor, it is apparently too late to
// prevent the dead timer from being called from g_timeout_dispatch() during
// the same iteration of g_main_dispatch(). A better solution must be found,
// possibly by deferring the timer deletion until later, this is only a
// temporary hack! (VZ)
// ----------------------------------------------------------------------------
static wxTimer *gs_timerDead = (wxTimer *)NULL;
// ----------------------------------------------------------------------------
// wxTimer // wxTimer
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject) IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
static gint timeout_callback( gpointer data ) static gint timeout_callback( gpointer data )
{ {
wxTimer *timer = (wxTimer*)data; wxTimer *timer = (wxTimer*)data;
if ( timer == gs_timerDead )
{
// shouldn't be called more than once for the dead timer anyhow
gs_timerDead = NULL;
return FALSE;
}
/* when getting called from GDK's timer handler we /* when getting called from GDK's timer handler we
are no longer within GDK's grab on the GUI are no longer within GDK's grab on the GUI
@@ -50,6 +69,8 @@ void wxTimer::Init()
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
gs_timerDead = this;
wxTimer::Stop(); wxTimer::Stop();
} }