From: Vadim Zeitlin Date: Mon, 1 Mar 2010 23:45:22 +0000 (+0000) Subject: Fix crash when accessing clipboard before entering the main loop. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/439c7eae9b77cc6c0414ccae52e688d626c86851 Fix crash when accessing clipboard before entering the main loop. Check that we have an event loop running before yielding to it. Notice that we really do need an event loop in wxClipboardSync as events must be dispatched for the clipboard code to work so while not using the event loop if it doesn't exist would have fixed a crash as well, it wouldn't allow to use the clipboard in e.g. wxApp-derived class OnInit(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index a3544a4103..8276951829 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); }