1 |
From 785f89233eb588447af2e5f712c2b555b4fbc344 Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Fri, 8 Jul 2016 14:50:56 +0100 |
4 |
Subject: [PATCH] Resolves: rhbz#1352965 gtk3 infinite clipboard recursion with |
5 |
clipit installed |
6 |
|
7 |
Change-Id: Ib67afaf532b8409e05fffbf1b8312d664460567d |
8 |
--- |
9 |
vcl/unx/gtk3/gtk3gtkinst.cxx | 11 ++++++----- |
10 |
1 file changed, 6 insertions(+), 5 deletions(-) |
11 |
|
12 |
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx |
13 |
index 25f4590..72599b2 100644 |
14 |
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx |
15 |
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx |
16 |
@@ -585,6 +585,7 @@ void VclGtkClipboard::setContents( |
17 |
{ |
18 |
osl::ClearableMutexGuard aGuard( m_aMutex ); |
19 |
Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner ); |
20 |
+ bool bOwnerChange = (xOldOwner.is() && xOldOwner != xClipboardOwner); |
21 |
Reference< datatransfer::XTransferable > xOldContents( m_aContents ); |
22 |
m_aContents = xTrans; |
23 |
m_aOwner = xClipboardOwner; |
24 |
@@ -592,6 +593,10 @@ void VclGtkClipboard::setContents( |
25 |
std::list< Reference< datatransfer::clipboard::XClipboardListener > > xListeners( m_aListeners ); |
26 |
datatransfer::clipboard::ClipboardEvent aEv; |
27 |
|
28 |
+ GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection); |
29 |
+ if (bOwnerChange) |
30 |
+ gtk_clipboard_clear(clipboard); |
31 |
+ assert(m_aGtkTargets.empty()); |
32 |
if (m_aContents.is()) |
33 |
{ |
34 |
css::uno::Sequence<css::datatransfer::DataFlavor> aFormats = xTrans->getTransferDataFlavors(); |
35 |
@@ -605,15 +610,11 @@ void VclGtkClipboard::setContents( |
36 |
aEntry.info = 0; |
37 |
aGtkTargets.push_back(aEntry); |
38 |
|
39 |
- GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection); |
40 |
gtk_clipboard_set_with_data(clipboard, aGtkTargets.data(), aGtkTargets.size(), |
41 |
ClipboardGetFunc, ClipboardClearFunc, this); |
42 |
gtk_clipboard_set_can_store(clipboard, aGtkTargets.data(), aGtkTargets.size()); |
43 |
} |
44 |
|
45 |
- for (auto &a : m_aGtkTargets) |
46 |
- g_free(a.target); |
47 |
- |
48 |
m_aGtkTargets = aGtkTargets; |
49 |
} |
50 |
|
51 |
@@ -621,7 +622,7 @@ void VclGtkClipboard::setContents( |
52 |
|
53 |
aGuard.clear(); |
54 |
|
55 |
- if( xOldOwner.is() && xOldOwner != xClipboardOwner ) |
56 |
+ if (bOwnerChange) |
57 |
xOldOwner->lostOwnership( this, xOldContents ); |
58 |
for( std::list< Reference< datatransfer::clipboard::XClipboardListener > >::iterator it = |
59 |
xListeners.begin(); it != xListeners.end() ; ++it ) |
60 |
-- |
61 |
2.7.4 |
62 |
|