X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10bd1f7d3bae0955cc7244c8c35d5e1151517c94..d968078adbfb147e913b9a33fc54242a36f117ce:/src/gtk/dnd.cpp diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index c995a53350..431141ef46 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -23,6 +23,8 @@ #include "wx/gdicmn.h" #endif +#include "wx/scopeguard.h" + #include //---------------------------------------------------------------------------- @@ -813,10 +815,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags) if (g_lastMouseEvent == NULL) return wxDragNone; - // disabled for now - g_blockEventsOnDrag = true; - - RegisterWindow(); + GTKConnectDragSignals(); + wxON_BLOCK_EXIT_OBJ0(*this, wxDropSource::GTKDisconnectDragSignals); m_waiting = true; @@ -850,6 +850,12 @@ wxDragResult wxDropSource::DoDragDrop(int flags) g_lastButtonNumber, // number of mouse button which started drag (GdkEvent*) g_lastMouseEvent ); + if ( !context ) + { + // this can happen e.g. if gdk_pointer_grab() failed + return wxDragError; + } + m_dragContext = context; PrepareIcon( action, context ); @@ -861,16 +867,15 @@ wxDragResult wxDropSource::DoDragDrop(int flags) if ( m_retValue == wxDragNone ) m_retValue = wxDragCancel; - g_blockEventsOnDrag = false; - - UnregisterWindow(); - return m_retValue; } -void wxDropSource::RegisterWindow() +void wxDropSource::GTKConnectDragSignals() { - if (!m_widget) return; + if (!m_widget) + return; + + g_blockEventsOnDrag = true; g_signal_connect (m_widget, "drag_data_get", G_CALLBACK (source_drag_data_get), this); @@ -879,11 +884,13 @@ void wxDropSource::RegisterWindow() } -void wxDropSource::UnregisterWindow() +void wxDropSource::GTKDisconnectDragSignals() { if (!m_widget) return; + g_blockEventsOnDrag = false; + g_signal_handlers_disconnect_by_func (m_widget, (gpointer) source_drag_data_get, this);