diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-07-12 20:31:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-12 20:33:11 +0100 |
commit | 962e0bb4b31265b046fe4fb57d3087e20f5fe4ef (patch) | |
tree | f8c26aebac957317c5a3cab4e1c3351ecb5ce435 | |
parent | 60a465026f4db1e05f771d9e6f422d7063b0ccd4 (diff) |
Related: rhbz#1351369 gtk3 clipboards have to live to end once created
like the other platforms do
Change-Id: I31340254573d13dc808d1e3038e3a36ae97f6c22
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 22 |
2 files changed, 20 insertions, 5 deletions
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 6212d5dcccba..01e8ca643f10 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 b5db25d63819..3cc404663976 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() |