X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..e5dcae09e6c207688b41c8b744764d32b7b39a46:/src/gtk/clipbrd.cpp?ds=sidebyside diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index d812143ab5..7fe76b4e66 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -75,6 +75,10 @@ public: ~wxClipboardSync() { + // ensure that there is a running event loop: this might not be the + // case if we're called before the main event loop startup + wxEventLoopGuarantor ensureEventLoop; + while (ms_clipboard) wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_CLIPBOARD); } @@ -481,11 +485,7 @@ GdkAtom wxClipboard::GTKGetClipboardAtom() const void wxClipboard::GTKClearData(Kind kind) { wxDataObject *&data = Data(kind); - if ( data ) - { - delete data; - data = NULL; - } + wxDELETE(data); } bool wxClipboard::SetSelectionOwner(bool set) @@ -564,6 +564,8 @@ bool wxClipboard::DoIsSupported(const wxDataFormat& format) void wxClipboard::Clear() { + gtk_selection_clear_targets( m_clipboardWidget, GTKGetClipboardAtom() ); + if ( gdk_selection_owner_get(GTKGetClipboardAtom()) == m_clipboardWidget->window ) { @@ -668,10 +670,11 @@ bool wxClipboard::GetData( wxDataObject& data ) { wxCHECK_MSG( m_open, false, wxT("clipboard not open") ); - // get all supported formats from wxDataObjects - const size_t count = data.GetFormatCount(); + // get all supported formats from wxDataObjects: notice that we are setting + // the object data, so we need them in "Set" direction + const size_t count = data.GetFormatCount(wxDataObject::Set); wxDataFormatArray formats(new wxDataFormat[count]); - data.GetAllFormats(formats.get()); + data.GetAllFormats(formats.get(), wxDataObject::Set); for ( size_t i = 0; i < count; i++ ) {