vcl/source/app/svmain.cxx       |   18 +++++++++---------
 vcl/win/dtrans/WinClipboard.cxx |   12 ++++++++++++
 vcl/win/dtrans/WinClipboard.hxx |    2 ++
 3 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit 8472365774b7471e96a025f424a6c7eb7b02db26
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Dec 4 15:08:26 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Dec 4 21:49:03 2023 +0100

    Avoid clipboard messages after Scheduler::ImplDeInitScheduler
    
    When running UITests on Windows with parallelism, often there are
    clipboard "content changed" messages that fail the assertion in
    Scheduler::ImplDeInitScheduler. This is because the clipboard is
    only uninitialized after the scheduler de-init; and even then,
    the respective threads are not stopped yet.
    
    Make sure that clipboard listeners are stopped before calling the
    Scheduler::ImplDeInitScheduler in DeInitVCL.
    
    Change-Id: I37918cdc565c7f1b3bd4f46e71c55bb5a807db6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160308
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 71dcca106a57..3aa2cecf4ec8 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -507,15 +507,6 @@ void DeInitVCL()
     // as this processes all pending events in debug builds.
     ImplGetSystemDependentDataManager().flushAll();
 
-    Scheduler::ImplDeInitScheduler();
-
-    pSVData->mpWinData->maMsgBoxImgList.clear();
-    pSVData->maCtrlData.maCheckImgList.clear();
-    pSVData->maCtrlData.maRadioImgList.clear();
-    pSVData->maCtrlData.moDisclosurePlus.reset();
-    pSVData->maCtrlData.moDisclosureMinus.reset();
-    pSVData->mpDefaultWin.disposeAndClear();
-
 #if defined _WIN32
     // See GetSystemClipboard (vcl/source/treelist/transfer2.cxx):
     if (auto const comp = css::uno::Reference<css::lang::XComponent>(
@@ -527,6 +518,15 @@ void DeInitVCL()
     pSVData->m_xSystemClipboard.clear();
 #endif
 
+    Scheduler::ImplDeInitScheduler();
+
+    pSVData->mpWinData->maMsgBoxImgList.clear();
+    pSVData->maCtrlData.maCheckImgList.clear();
+    pSVData->maCtrlData.maRadioImgList.clear();
+    pSVData->maCtrlData.moDisclosurePlus.reset();
+    pSVData->maCtrlData.moDisclosureMinus.reset();
+    pSVData->mpDefaultWin.disposeAndClear();
+
 #ifndef NDEBUG
     DbgGUIDeInitSolarMutexCheck();
 #endif
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx
index f82c56784523..1a8eaea151b5 100644
--- a/vcl/win/dtrans/WinClipboard.cxx
+++ b/vcl/win/dtrans/WinClipboard.cxx
@@ -82,6 +82,18 @@ CWinClipboard::~CWinClipboard()
     unregisterClipboardViewer();
 }
 
+void CWinClipboard::disposing(std::unique_lock<std::mutex>& mutex)
+{
+    {
+        osl::MutexGuard aGuard(s_aClipboardSingletonMutex);
+        s_pCWinClipbImpl = nullptr;
+    }
+
+    unregisterClipboardViewer();
+
+    WeakComponentImplHelper::disposing(mutex);
+}
+
 // XClipboard
 
 // to avoid unnecessary traffic we check first if there is a clipboard
diff --git a/vcl/win/dtrans/WinClipboard.hxx b/vcl/win/dtrans/WinClipboard.hxx
index 779c272c56c9..fbaa1b206288 100644
--- a/vcl/win/dtrans/WinClipboard.hxx
+++ b/vcl/win/dtrans/WinClipboard.hxx
@@ -105,6 +105,8 @@ public:
     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() 
override;
 
     IDataObjectPtr getIDataObject();
+
+    virtual void disposing(std::unique_lock<std::mutex>&) override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to