Blame 0001-Resolves-rhbz-1352965-gtk3-infinite-clipboard-recurs.patch

10161a6
From 25477cb518a464fb052e55c2b7c250af606ba42d Mon Sep 17 00:00:00 2001
9ce5efc
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
9ce5efc
Date: Fri, 8 Jul 2016 14:50:56 +0100
9ce5efc
Subject: [PATCH] Resolves: rhbz#1352965 gtk3 infinite clipboard recursion with
9ce5efc
 clipit installed
9ce5efc
9ce5efc
Change-Id: Ib67afaf532b8409e05fffbf1b8312d664460567d
9ce5efc
---
9ce5efc
 vcl/unx/gtk3/gtk3gtkinst.cxx | 11 ++++++-----
9ce5efc
 1 file changed, 6 insertions(+), 5 deletions(-)
9ce5efc
9ce5efc
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
10161a6
index 8b01166..c92bf43 100644
9ce5efc
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
9ce5efc
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
10161a6
@@ -587,6 +587,7 @@ void VclGtkClipboard::setContents(
9ce5efc
 {
9ce5efc
     osl::ClearableMutexGuard aGuard( m_aMutex );
9ce5efc
     Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
9ce5efc
+    bool bOwnerChange = (xOldOwner.is() && xOldOwner != xClipboardOwner);
9ce5efc
     Reference< datatransfer::XTransferable > xOldContents( m_aContents );
9ce5efc
     m_aContents = xTrans;
9ce5efc
     m_aOwner = xClipboardOwner;
10161a6
@@ -594,6 +595,10 @@ void VclGtkClipboard::setContents(
10161a6
     std::list< Reference< datatransfer::clipboard::XClipboardListener > > aListeners( m_aListeners );
9ce5efc
     datatransfer::clipboard::ClipboardEvent aEv;
9ce5efc
 
9ce5efc
+    GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
9ce5efc
+    if (bOwnerChange)
9ce5efc
+        gtk_clipboard_clear(clipboard);
9ce5efc
+    assert(m_aGtkTargets.empty());
9ce5efc
     if (m_aContents.is())
9ce5efc
     {
9ce5efc
         css::uno::Sequence<css::datatransfer::DataFlavor> aFormats = xTrans->getTransferDataFlavors();
10161a6
@@ -607,15 +612,11 @@ void VclGtkClipboard::setContents(
9ce5efc
             aEntry.info = 0;
9ce5efc
             aGtkTargets.push_back(aEntry);
9ce5efc
 
9ce5efc
-            GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
9ce5efc
             gtk_clipboard_set_with_data(clipboard, aGtkTargets.data(), aGtkTargets.size(),
9ce5efc
                                         ClipboardGetFunc, ClipboardClearFunc, this);
9ce5efc
             gtk_clipboard_set_can_store(clipboard, aGtkTargets.data(), aGtkTargets.size());
9ce5efc
         }
9ce5efc
 
9ce5efc
-        for (auto &a : m_aGtkTargets)
9ce5efc
-            g_free(a.target);
9ce5efc
-
9ce5efc
         m_aGtkTargets = aGtkTargets;
9ce5efc
     }
9ce5efc
 
10161a6
@@ -623,7 +624,7 @@ void VclGtkClipboard::setContents(
9ce5efc
 
9ce5efc
     aGuard.clear();
9ce5efc
 
9ce5efc
-    if( xOldOwner.is() && xOldOwner != xClipboardOwner )
9ce5efc
+    if (bOwnerChange)
9ce5efc
         xOldOwner->lostOwnership( this, xOldContents );
9ce5efc
     for( std::list< Reference< datatransfer::clipboard::XClipboardListener > >::iterator it =
10161a6
          aListeners.begin(); it != aListeners.end() ; ++it )
9ce5efc
-- 
9ce5efc
2.7.4
9ce5efc