diff options
Diffstat (limited to 'vcl/win/dtrans/WinClipboard.cxx')
-rw-r--r-- | vcl/win/dtrans/WinClipboard.cxx | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx index 1f49bde99192..f50c1810f4ea 100644 --- a/vcl/win/dtrans/WinClipboard.cxx +++ b/vcl/win/dtrans/WinClipboard.cxx @@ -27,8 +27,6 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> -#include <tools/debug.hxx> -#include <vcl/svapp.hxx> #include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp> #include "XNotifyingDataObject.hxx" @@ -65,11 +63,6 @@ CWinClipboard::CWinClipboard(const uno::Reference<uno::XComponentContext>& rxCon // the static callback function s_pCWinClipbImpl = this; registerClipboardViewer(); - - m_aNotifyClipboardChangeIdle.SetDebugName("CWinClipboard::m_aNotifyClipboardChangeIdle"); - m_aNotifyClipboardChangeIdle.SetPriority(TaskPriority::HIGH_IDLE); - m_aNotifyClipboardChangeIdle.SetInvokeHandler( - LINK(this, CWinClipboard, ClipboardContentChangedHdl)); } CWinClipboard::~CWinClipboard() @@ -126,14 +119,8 @@ uno::Reference<datatransfer::XTransferable> SAL_CALL CWinClipboard::getContents( // com smart pointer to the IDataObject from clipboard IDataObjectPtr pIDo(new CAPNDataObject(pIDataObject)); - { - // before calling COM methods of an apartment-threaded COM object, release solar mutex - // to avoid deadlocking on waiting clipboard thread that would try to acquire it - SolarMutexReleaserIfAcquired aReleaser; - - // remember pIDo destroys itself due to the smart pointer - rClipContent = CDOTransferable::create(m_xContext, pIDo); - } + // remember pIDo destroys itself due to the smart pointer + rClipContent = CDOTransferable::create(m_xContext, pIDo); osl::MutexGuard aGuard2(m_ClipContentMutex); m_foreignContent = rClipContent; @@ -249,11 +236,8 @@ void SAL_CALL CWinClipboard::removeClipboardListener( rBHelper.aLC.removeInterface(cppu::UnoType<decltype(listener)>::get(), listener); } -IMPL_LINK_NOARG(CWinClipboard, ClipboardContentChangedHdl, Timer*, void) +void CWinClipboard::notifyAllClipboardListener() { - DBG_TESTSOLARMUTEX(); - SolarMutexReleaser aReleaser; - if (rBHelper.bDisposed) return; @@ -270,11 +254,7 @@ IMPL_LINK_NOARG(CWinClipboard, ClipboardContentChangedHdl, Timer*, void) try { cppu::OInterfaceIteratorHelper iter(*pICHelper); - uno::Reference<datatransfer::XTransferable> rXTransf; - { - SolarMutexGuard aGuard; - rXTransf.set(getContents()); - } + uno::Reference<datatransfer::XTransferable> rXTransf(getContents()); datatransfer::clipboard::ClipboardEvent aClipbEvent(static_cast<XClipboard*>(this), rXTransf); @@ -343,22 +323,21 @@ void CWinClipboard::onReleaseDataObject(CXNotifyingDataObject* theCaller) void CWinClipboard::registerClipboardViewer() { - m_MtaOleClipboard.registerClipViewer(CWinClipboard::onWM_CLIPBOARDUPDATE); + m_MtaOleClipboard.registerClipViewer(CWinClipboard::onClipboardContentChanged); } void CWinClipboard::unregisterClipboardViewer() { m_MtaOleClipboard.registerClipViewer(nullptr); } -void WINAPI CWinClipboard::onWM_CLIPBOARDUPDATE() +void WINAPI CWinClipboard::onClipboardContentChanged() { osl::MutexGuard aGuard(s_aMutex); - if (!s_pCWinClipbImpl) - return; - - s_pCWinClipbImpl->m_foreignContent.clear(); - - if (!s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.IsActive()) - s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.Start(); + // reassociation to instance through static member + if (nullptr != s_pCWinClipbImpl) + { + s_pCWinClipbImpl->m_foreignContent.clear(); + s_pCWinClipbImpl->notifyAllClipboardListener(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |