X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eddb964405c1db1a931a347611aed0af6ee0e3b7..8ca1a013e4e699724040ff1f514dab3b4a11d3c9:/src/gtk/clipbrd.cpp diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index e6b79180a1..483b6beca4 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -88,6 +88,17 @@ public: ms_clipboard = NULL; } + // this method should be called if it's possible that no async clipboard + // operation is currently in progress (like it can be the case when the + // clipboard is cleared but not because we asked about it), it should only + // be called if such situation is expected -- otherwise call OnDone() which + // would assert in this case + static void OnDoneIfInProgress(wxClipboard *clipboard) + { + if ( ms_clipboard ) + OnDone(clipboard); + } + private: static wxClipboard *ms_clipboard; @@ -199,7 +210,12 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) if ( !clipboard ) return TRUE; - wxON_BLOCK_EXIT1(wxClipboardSync::OnDone, clipboard); + // notice the use of OnDoneIfInProgress() here instead of just OnDone(): + // it's perfectly possible that we're receiving this notification from GTK+ + // even though we hadn't cleared the clipboard ourselves but because + // another application (or even another window in the same program) + // acquired it + wxON_BLOCK_EXIT1(wxClipboardSync::OnDoneIfInProgress, clipboard); wxClipboard::Kind kind; if (event->selection == GDK_SELECTION_PRIMARY) @@ -347,8 +363,6 @@ wxClipboard::wxClipboard() m_formatSupported = false; m_targetRequested = 0; - m_usePrimary = false; - // we use m_targetsWidget to query what formats are available m_targetsWidget = gtk_window_new( GTK_WINDOW_POPUP ); gtk_widget_realize( m_targetsWidget ); @@ -379,10 +393,8 @@ wxClipboard::~wxClipboard() { Clear(); - if ( m_clipboardWidget ) - gtk_widget_destroy( m_clipboardWidget ); - if ( m_targetsWidget ) - gtk_widget_destroy( m_targetsWidget ); + gtk_widget_destroy( m_clipboardWidget ); + gtk_widget_destroy( m_targetsWidget ); } // ---------------------------------------------------------------------------- @@ -427,7 +439,7 @@ void wxClipboard::AddSupportedTarget(GdkAtom atom) { gtk_selection_add_target ( - GTK_WIDGET(m_clipboardWidget), + m_clipboardWidget, GTKGetClipboardAtom(), atom, 0 // info (same as client data) unused