From a2d51707f9fb5d26bbd935eb4b82569e9db400b9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 12 Aug 2000 16:19:04 +0000 Subject: [PATCH] I hope dnd won't crash anymore and I didn't break too much else. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8053 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 10 ++++++++++ src/gtk/dnd.cpp | 13 +++++++++++-- src/gtk1/app.cpp | 10 ++++++++++ src/gtk1/dnd.cpp | 13 +++++++++++-- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 7505f40b8a..86b12cebfb 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -186,8 +186,14 @@ void wxapp_install_idle_handler() #if wxUSE_THREADS +static int g_threadUninstallLevel = 0; + void wxapp_install_thread_wakeup() { + g_threadUninstallLevel++; + + if (g_threadUninstallLevel != 1) return; + if (wxTheApp->m_wakeUpTimerTag) return; wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL ); @@ -195,6 +201,10 @@ void wxapp_install_thread_wakeup() void wxapp_uninstall_thread_wakeup() { + g_threadUninstallLevel--; + + if (g_threadUninstallLevel != 0) return; + if (!wxTheApp->m_wakeUpTimerTag) return; gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag ); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index a041507bf0..ca9e7fdf16 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -226,6 +226,11 @@ static gboolean target_drag_drop( GtkWidget *widget, if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; */ + /* reset the block here as someone might very well + show a dialog as a reaction to a drop and this + wouldn't work without events */ + g_blockEventsOnDrag = FALSE; + bool ret = drop_target->OnDrop( x, y ); if (!ret) @@ -736,8 +741,12 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) if (m_data->GetFormatCount() == 0) return (wxDragResult) wxDragNone; + // still in drag + if (g_blockEventsOnDrag) + return (wxDragResult) wxDragNone; + // disabled for now - g_blockEventsOnDrag = FALSE; + g_blockEventsOnDrag = TRUE; RegisterWindow(); @@ -806,7 +815,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) #endif g_blockEventsOnDrag = FALSE; - + UnregisterWindow(); return m_retValue; diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 7505f40b8a..86b12cebfb 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -186,8 +186,14 @@ void wxapp_install_idle_handler() #if wxUSE_THREADS +static int g_threadUninstallLevel = 0; + void wxapp_install_thread_wakeup() { + g_threadUninstallLevel++; + + if (g_threadUninstallLevel != 1) return; + if (wxTheApp->m_wakeUpTimerTag) return; wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL ); @@ -195,6 +201,10 @@ void wxapp_install_thread_wakeup() void wxapp_uninstall_thread_wakeup() { + g_threadUninstallLevel--; + + if (g_threadUninstallLevel != 0) return; + if (!wxTheApp->m_wakeUpTimerTag) return; gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag ); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index a041507bf0..ca9e7fdf16 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -226,6 +226,11 @@ static gboolean target_drag_drop( GtkWidget *widget, if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; */ + /* reset the block here as someone might very well + show a dialog as a reaction to a drop and this + wouldn't work without events */ + g_blockEventsOnDrag = FALSE; + bool ret = drop_target->OnDrop( x, y ); if (!ret) @@ -736,8 +741,12 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) if (m_data->GetFormatCount() == 0) return (wxDragResult) wxDragNone; + // still in drag + if (g_blockEventsOnDrag) + return (wxDragResult) wxDragNone; + // disabled for now - g_blockEventsOnDrag = FALSE; + g_blockEventsOnDrag = TRUE; RegisterWindow(); @@ -806,7 +815,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) #endif g_blockEventsOnDrag = FALSE; - + UnregisterWindow(); return m_retValue;