vcl/win/dtrans/WinClipboard.cxx |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit f5ab8bcbfd20ecce4a358f62ee3f81b8b968a5de
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Mon Dec 14 10:47:04 2020 +0100
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Wed Dec 16 18:02:15 2020 +0100

    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 <glo...@fbihome.de>

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();
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to