From b2b510728e3d5bc585a534563d013394d647caaf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 1 Apr 2007 21:52:27 +0000 Subject: [PATCH] avoid asserts when the cipboard is acquired by another application git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45209 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/clipbrd.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 628a663fbd..ea30f41d24 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) -- 2.45.2