handle failure of gtk_drag_begin() (which can happen e.g. because gdk_pointer_grab() failed) in DoDragDrop() (patch 1825237) + minor cleanup in trunk version of the code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -80,10 +80,6 @@ public:
 | 
				
			|||||||
    // start drag action
 | 
					    // start drag action
 | 
				
			||||||
    virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
 | 
					    virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // GTK implementation
 | 
					 | 
				
			||||||
    void RegisterWindow();
 | 
					 | 
				
			||||||
    void UnregisterWindow();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void PrepareIcon( int action, GdkDragContext *context );
 | 
					    void PrepareIcon( int action, GdkDragContext *context );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GtkWidget       *m_widget;
 | 
					    GtkWidget       *m_widget;
 | 
				
			||||||
@@ -103,6 +99,11 @@ private:
 | 
				
			|||||||
    void SetIcons(const wxIcon& copy,
 | 
					    void SetIcons(const wxIcon& copy,
 | 
				
			||||||
                  const wxIcon& move,
 | 
					                  const wxIcon& move,
 | 
				
			||||||
                  const wxIcon& none);
 | 
					                  const wxIcon& none);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // GTK implementation
 | 
				
			||||||
 | 
					    void GTKConnectDragSignals();
 | 
				
			||||||
 | 
					    void GTKDisconnectDragSignals();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _WX_GTK_DND_H_
 | 
					#endif // _WX_GTK_DND_H_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,8 @@
 | 
				
			|||||||
    #include "wx/gdicmn.h"
 | 
					    #include "wx/gdicmn.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "wx/scopeguard.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gtk/gtk.h>
 | 
					#include <gtk/gtk.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//----------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------
 | 
				
			||||||
@@ -813,10 +815,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
 | 
				
			|||||||
    if (g_lastMouseEvent == NULL)
 | 
					    if (g_lastMouseEvent == NULL)
 | 
				
			||||||
        return wxDragNone;
 | 
					        return wxDragNone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // disabled for now
 | 
					    GTKConnectDragSignals();
 | 
				
			||||||
    g_blockEventsOnDrag = true;
 | 
					    wxON_BLOCK_EXIT_OBJ0(*this, wxDropSource::GTKDisconnectDragSignals);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    RegisterWindow();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_waiting = true;
 | 
					    m_waiting = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -850,6 +850,12 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
 | 
				
			|||||||
                g_lastButtonNumber,  // number of mouse button which started drag
 | 
					                g_lastButtonNumber,  // number of mouse button which started drag
 | 
				
			||||||
                (GdkEvent*) g_lastMouseEvent );
 | 
					                (GdkEvent*) g_lastMouseEvent );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ( !context )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // this can happen e.g. if gdk_pointer_grab() failed
 | 
				
			||||||
 | 
					        return wxDragError;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_dragContext = context;
 | 
					    m_dragContext = context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrepareIcon( action, context );
 | 
					    PrepareIcon( action, context );
 | 
				
			||||||
@@ -861,16 +867,15 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
 | 
				
			|||||||
    if ( m_retValue == wxDragNone )
 | 
					    if ( m_retValue == wxDragNone )
 | 
				
			||||||
         m_retValue = wxDragCancel;
 | 
					         m_retValue = wxDragCancel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_blockEventsOnDrag = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    UnregisterWindow();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return m_retValue;
 | 
					    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_signal_connect (m_widget, "drag_data_get",
 | 
				
			||||||
                      G_CALLBACK (source_drag_data_get), this);
 | 
					                      G_CALLBACK (source_drag_data_get), this);
 | 
				
			||||||
@@ -879,11 +884,13 @@ void wxDropSource::RegisterWindow()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wxDropSource::UnregisterWindow()
 | 
					void wxDropSource::GTKDisconnectDragSignals()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!m_widget)
 | 
					    if (!m_widget)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    g_blockEventsOnDrag = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_signal_handlers_disconnect_by_func (m_widget,
 | 
					    g_signal_handlers_disconnect_by_func (m_widget,
 | 
				
			||||||
                                          (gpointer) source_drag_data_get,
 | 
					                                          (gpointer) source_drag_data_get,
 | 
				
			||||||
                                          this);
 | 
					                                          this);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user