[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara
caolanm at redhat.com
Tue Jul 12 19:33:38 UTC 2016
vcl/inc/unx/gtk/gtkinst.hxx | 3 +++
vcl/unx/gtk3/gtk3gtkinst.cxx | 22 +++++++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
New commits:
commit 962e0bb4b31265b046fe4fb57d3087e20f5fe4ef
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Jul 12 20:31:52 2016 +0100
Related: rhbz#1351369 gtk3 clipboards have to live to end once created
like the other platforms do
Change-Id: I31340254573d13dc808d1e3038e3a36ae97f6c22
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 6212d5d..01e8ca6 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -246,6 +246,9 @@ public:
private:
std::vector<GtkSalTimer *> m_aTimers;
+#if GTK_CHECK_VERSION(3,0,0)
+ std::unordered_map< GdkAtom, css::uno::Reference<css::uno::XInterface> > m_aClipboards;
+#endif
bool IsTimerExpired();
bool bNeedsInit;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index b5db25d..3cc4046 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -536,7 +536,11 @@ VclGtkClipboard::~VclGtkClipboard()
{
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
g_signal_handler_disconnect(clipboard, m_nOwnerChangedSignalId);
- ClipboardClear(nullptr);
+ if (!m_aGtkTargets.empty())
+ {
+ gtk_clipboard_clear(clipboard);
+ }
+ assert(m_aGtkTargets.empty());
}
std::vector<GtkTargetEntry> VclToGtkHelper::FormatsToGtk(const css::uno::Sequence<css::datatransfer::DataFlavor> &rFormats)
@@ -587,7 +591,6 @@ void VclGtkClipboard::setContents(
{
osl::ClearableMutexGuard aGuard( m_aMutex );
Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
- bool bOwnerChange = (xOldOwner.is() && xOldOwner != xClipboardOwner);
Reference< datatransfer::XTransferable > xOldContents( m_aContents );
m_aContents = xTrans;
m_aOwner = xClipboardOwner;
@@ -596,8 +599,10 @@ void VclGtkClipboard::setContents(
datatransfer::clipboard::ClipboardEvent aEv;
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
- if (bOwnerChange)
+ if (!m_aGtkTargets.empty())
+ {
gtk_clipboard_clear(clipboard);
+ }
assert(m_aGtkTargets.empty());
if (m_aContents.is())
{
@@ -624,7 +629,7 @@ void VclGtkClipboard::setContents(
aGuard.clear();
- if (bOwnerChange)
+ if (xOldOwner.is() && xOldOwner != xClipboardOwner)
xOldOwner->lostOwnership( this, xOldContents );
for( std::list< Reference< datatransfer::clipboard::XClipboardListener > >::iterator it =
aListeners.begin(); it != aListeners.end() ; ++it )
@@ -672,7 +677,14 @@ Reference< XInterface > GtkInstance::CreateClipboard(const Sequence< Any >& argu
GdkAtom nSelection = (sel == "CLIPBOARD") ? GDK_SELECTION_CLIPBOARD : GDK_SELECTION_PRIMARY;
- return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new VclGtkClipboard(nSelection)) );
+ auto it = m_aClipboards.find(nSelection);
+ if (it != m_aClipboards.end())
+ return it->second;
+
+ Reference<XInterface> xClipboard(static_cast<cppu::OWeakObject *>(new VclGtkClipboard(nSelection)));
+ m_aClipboards[nSelection] = xClipboard;
+
+ return xClipboard;
}
GtkDropTarget::GtkDropTarget()
More information about the Libreoffice-commits
mailing list