bug 1590965 call gtk_clipboard_store() from an event r=stransky
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 07 Nov 2019 22:42:13 +0000
changeset 501674 e327b9536917f0247ba28d5e5f8c737f7338317a
parent 501673 610f0e00fbbaf19e502b48b28d33c11e757c3526
child 501675 4c34130cc58ff8d8efbbd2c1e8190f4982ee4223
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1590965
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1590965 call gtk_clipboard_store() from an event r=stransky Differential Revision: https://phabricator.services.mozilla.com/D50538
widget/gtk/nsClipboard.cpp
--- a/widget/gtk/nsClipboard.cpp
+++ b/widget/gtk/nsClipboard.cpp
@@ -107,19 +107,24 @@ nsresult nsClipboard::Init(void) {
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsClipboard::Observe(nsISupports* aSubject, const char* aTopic,
                      const char16_t* aData) {
-  // Save global clipboard content to CLIPBOARD_MANAGER
-  gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
-  return NS_OK;
+  // Save global clipboard content to CLIPBOARD_MANAGER.
+  // gtk_clipboard_store() can run an event loop, so call from a dedicated
+  // runnable.
+  return SystemGroup::Dispatch(
+      TaskCategory::Other,
+      NS_NewRunnableFunction("gtk_clipboard_store()", []() {
+        gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+      }));
 }
 
 NS_IMETHODIMP
 nsClipboard::SetData(nsITransferable* aTransferable, nsIClipboardOwner* aOwner,
                      int32_t aWhichClipboard) {
   // See if we can short cut
   if ((aWhichClipboard == kGlobalClipboard &&
        aTransferable == mGlobalTransferable.get() &&