diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-10-02 13:31:46 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-10-07 16:02:31 +0200 |
commit | 29e12fe99d38ce2a35b946f6a851940e347713dd (patch) | |
tree | 293ce87d4701889562c62e16b347593dac607d0b /vcl/qt5/Qt5Clipboard.cxx | |
parent | 1506c5e1f7228b23b8cee461701ab9dc8eccde27 (diff) |
tdf#112368 Qt5 don't lose ownership in flushClipboard
I didn't know that flushClipboard is called for simple text edit
fields for C'n'P operations, and not just on LO shutdown. This way
the simple text is actually secured in the clipboard instandly, as
there aren't complex mime-types to generate and secure.
As a result we also need to protect flushClipboard from loosing
ownership, which wasn't needed for the shutdown-only case, as this
would give up ownership anyway.
Change-Id: Ib3cd4979228fc645a27c658abb3df38ccf8c8956
Reviewed-on: https://gerrit.libreoffice.org/80042
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5/Qt5Clipboard.cxx')
-rw-r--r-- | vcl/qt5/Qt5Clipboard.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx index 4b31864bf2bd..cadedbfd327e 100644 --- a/vcl/qt5/Qt5Clipboard.cxx +++ b/vcl/qt5/Qt5Clipboard.cxx @@ -29,7 +29,7 @@ Qt5Clipboard::Qt5Clipboard(const OUString& aModeString, const QClipboard::Mode a XServiceInfo>(m_aMutex) , m_aClipboardName(aModeString) , m_aClipboardMode(aMode) - , m_bInSetContents(false) + , m_bOwnClipboardChange(false) { assert(isSupported(m_aClipboardMode)); // DirectConnection guarantees the changed slot runs in the same thread as the QClipboard @@ -66,7 +66,11 @@ void Qt5Clipboard::flushClipboard() QMimeData* pMimeCopy = nullptr; if (pQt5MimeData && pQt5MimeData->deepCopy(&pMimeCopy)) + { + m_bOwnClipboardChange = true; pClipboard->setMimeData(pMimeCopy, m_aClipboardMode); + m_bOwnClipboardChange = false; + } }); } @@ -106,9 +110,7 @@ void Qt5Clipboard::setContents( m_aContents = xTrans; m_aOwner = xClipboardOwner; - // these QApplication::clipboard() calls will trigger QClipboard::changed / handleChanged. - // we need to prevent freeing the contents, so tell handleChanged about us setting it - m_bInSetContents = true; + m_bOwnClipboardChange = true; if (m_aContents.is()) QApplication::clipboard()->setMimeData(new Qt5MimeData(m_aContents), m_aClipboardMode); else @@ -116,7 +118,7 @@ void Qt5Clipboard::setContents( assert(!m_aOwner.is()); QApplication::clipboard()->clear(m_aClipboardMode); } - m_bInSetContents = false; + m_bOwnClipboardChange = false; aGuard.clear(); @@ -136,7 +138,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode) css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner> xOldOwner(m_aOwner); css::uno::Reference<css::datatransfer::XTransferable> xOldContents(m_aContents); // ownership change from LO POV is handled in setContents - if (!m_bInSetContents) + if (!m_bOwnClipboardChange) { m_aContents.clear(); m_aOwner.clear(); @@ -149,7 +151,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode) aGuard.clear(); - if (!m_bInSetContents && xOldOwner.is()) + if (!m_bOwnClipboardChange && xOldOwner.is()) xOldOwner->lostOwnership(this, xOldContents); for (auto const& listener : aListeners) listener->changedContents(aEv); |