diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-09-22 10:40:23 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-12-13 12:18:47 +0100 |
commit | 9617bc9544cd569066ff187c3672a87fe28fe17f (patch) | |
tree | f044537b8b05dc08b622dfbc942633b8c4919977 /vcl/win/dtrans/WinClipboard.cxx | |
parent | 1d9f243a39169256ebb923afb32fffecf04ac427 (diff) |
WIN replace clipboard update thread with Idle
Little "fallout" patch when moving code from /dtrans/** to
/vcl/win/dtrans and merging CWinClipbImpl into CWinClipboard
while I tried to reproduce tdf#62196...
And since we now process the notification in the main thread, we
can get rid of m_pfncClipViewerCallbackMutex, which brings us down
from 6 (!) to 4 mutexes (if Mike counted correct) in the Windows
clipboard code... ok, technically the scheduler / Idle adds its
mutex to this count, but that is not related to the clipboard
handling on Windows ;-)
This also moves the UnregisterClassW into the OLE thread, which
already calls RegisterClassW, to be more consistent.
This now also gets merged, because it seem to fix a deadlocks when
running CppunitTest_sc_macros_test in a loop, which is unclear
where it comes from and I can't reproduce. Tinderboxes and Gerrit
also still seem fine.
Change-Id: Iacbda0bdf6c98f27f6e59964d541524cb45ade24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107168
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/win/dtrans/WinClipboard.cxx')
-rw-r--r-- | vcl/win/dtrans/WinClipboard.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx index f50c1810f4ea..121b945ff4e9 100644 --- a/vcl/win/dtrans/WinClipboard.cxx +++ b/vcl/win/dtrans/WinClipboard.cxx @@ -63,6 +63,11 @@ 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() @@ -236,8 +241,10 @@ void SAL_CALL CWinClipboard::removeClipboardListener( rBHelper.aLC.removeInterface(cppu::UnoType<decltype(listener)>::get(), listener); } -void CWinClipboard::notifyAllClipboardListener() +IMPL_LINK_NOARG(CWinClipboard, ClipboardContentChangedHdl, Timer*, void) { + m_foreignContent.clear(); + if (rBHelper.bDisposed) return; @@ -323,21 +330,20 @@ void CWinClipboard::onReleaseDataObject(CXNotifyingDataObject* theCaller) void CWinClipboard::registerClipboardViewer() { - m_MtaOleClipboard.registerClipViewer(CWinClipboard::onClipboardContentChanged); + m_MtaOleClipboard.registerClipViewer(CWinClipboard::onWM_CLIPBOARDUPDATE); } void CWinClipboard::unregisterClipboardViewer() { m_MtaOleClipboard.registerClipViewer(nullptr); } -void WINAPI CWinClipboard::onClipboardContentChanged() +void WINAPI CWinClipboard::onWM_CLIPBOARDUPDATE() { osl::MutexGuard aGuard(s_aMutex); - // reassociation to instance through static member - if (nullptr != s_pCWinClipbImpl) - { - s_pCWinClipbImpl->m_foreignContent.clear(); - s_pCWinClipbImpl->notifyAllClipboardListener(); - } + if (!s_pCWinClipbImpl) + return; + + if (!s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.IsActive()) + s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.Start(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |