summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2020-12-14 10:47:04 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2020-12-16 18:02:15 +0100
commitf5ab8bcbfd20ecce4a358f62ee3f81b8b968a5de (patch)
tree78eeb346b2bd8a875becb3dcde7e766400e49fce
parente4c21a3c1fa8acd0078029d7a42f304ff2b40773 (diff)
WIN don't notify clipboard change with SolarMutex
Regression from commit 52a7eb58f5c137b6de76cc49be07dd43c42a6d6c ("WIN replace clipboard update thread with Idle"). Previously the notification was done without the SolarMutex. Now it's run via an Idle and SolarMutex is required by the Scheduler, so release it. Foreign contents is again protected by the clipboard lock. And also unlock the SolarMutex in getContents, to prevent a deadlock in the clipboard STA thread, if it's already processing other request, like CXNotifyingDataObject::GetData, blocking on the SolarMutex. Change-Id: I6855b045b3065289ec7833498f6785ee31eda61c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107675 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r--vcl/win/dtrans/WinClipboard.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx
index 121b945ff4e9..4135b5cef93c 100644
--- a/vcl/win/dtrans/WinClipboard.cxx
+++ b/vcl/win/dtrans/WinClipboard.cxx
@@ -27,6 +27,8 @@
#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"
@@ -90,6 +92,9 @@ CWinClipboard::~CWinClipboard()
uno::Reference<datatransfer::XTransferable> SAL_CALL CWinClipboard::getContents()
{
+ DBG_TESTSOLARMUTEX();
+ SolarMutexReleaser aReleaser;
+
osl::MutexGuard aGuard(m_aMutex);
if (rBHelper.bDisposed)
@@ -243,7 +248,8 @@ void SAL_CALL CWinClipboard::removeClipboardListener(
IMPL_LINK_NOARG(CWinClipboard, ClipboardContentChangedHdl, Timer*, void)
{
- m_foreignContent.clear();
+ DBG_TESTSOLARMUTEX();
+ SolarMutexReleaser aReleaser;
if (rBHelper.bDisposed)
return;
@@ -261,7 +267,11 @@ IMPL_LINK_NOARG(CWinClipboard, ClipboardContentChangedHdl, Timer*, void)
try
{
cppu::OInterfaceIteratorHelper iter(*pICHelper);
- uno::Reference<datatransfer::XTransferable> rXTransf(getContents());
+ uno::Reference<datatransfer::XTransferable> rXTransf;
+ {
+ SolarMutexGuard aGuard;
+ rXTransf.set(getContents());
+ }
datatransfer::clipboard::ClipboardEvent aClipbEvent(static_cast<XClipboard*>(this),
rXTransf);
@@ -342,6 +352,8 @@ void WINAPI CWinClipboard::onWM_CLIPBOARDUPDATE()
if (!s_pCWinClipbImpl)
return;
+ s_pCWinClipbImpl->m_foreignContent.clear();
+
if (!s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.IsActive())
s_pCWinClipbImpl->m_aNotifyClipboardChangeIdle.Start();
}