[Libreoffice-commits] core.git: vcl/vclplug_win.component vcl/win

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 1 07:48:46 UTC 2020


 vcl/vclplug_win.component       |    5 +----
 vcl/win/dtrans/WinClipboard.cxx |   28 +---------------------------
 vcl/win/dtrans/WinClipboard.hxx |    2 --
 3 files changed, 2 insertions(+), 33 deletions(-)

New commits:
commit d12d236bac476ba39ee41b7d5bc7b849b4fd52c6
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 30 22:33:33 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Oct 1 09:47:51 2020 +0200

    Use the new single-instance="true" attribute in vcl
    
    Change-Id: I6067761fda821b90fdd5c57a2c934c9626e92fdf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103739
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/vclplug_win.component b/vcl/vclplug_win.component
index db79a027510e..d6dc9f24e93f 100644
--- a/vcl/vclplug_win.component
+++ b/vcl/vclplug_win.component
@@ -40,10 +40,7 @@
     <service name="com.sun.star.datatransfer.clipboard.GenericClipboard"/>
   </implementation>
   <implementation name="com.sun.star.datatransfer.clipboard.ClipboardW32"
-        constructor="dtrans_CWinClipboard_get_implementation">
+        constructor="dtrans_CWinClipboard_get_implementation" single-instance="true">
     <service name="com.sun.star.datatransfer.clipboard.SystemClipboard"/>
-    <!-- Fake singleton so the servicemanager shuts us down and we can clean up our global instance
-         var: -->
-    <singleton name="com.sun.star.datatransfer.clipboard.theSystemClipboard"/>
   </implementation>
 </component>
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx
index 17477fd8d16d..de6ecb775838 100644
--- a/vcl/win/dtrans/WinClipboard.cxx
+++ b/vcl/win/dtrans/WinClipboard.cxx
@@ -19,8 +19,6 @@
 
 #include <sal/config.h>
 
-#include <mutex>
-
 #include <osl/diagnose.h>
 #include <com/sun/star/datatransfer/clipboard/ClipboardEvent.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
@@ -28,7 +26,6 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/weak.hxx>
-#include <rtl/ref.hxx>
 
 #include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
 #include "XNotifyingDataObject.hxx"
@@ -301,27 +298,11 @@ uno::Sequence<OUString> SAL_CALL CWinClipboard::getSupportedServiceNames()
     return { "com.sun.star.datatransfer.clipboard.SystemClipboard" };
 }
 
-namespace
-{
-std::mutex g_InstanceGuard;
-rtl::Reference<CWinClipboard> g_Instance;
-bool g_Disposed = false;
-}
-
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 dtrans_CWinClipboard_get_implementation(css::uno::XComponentContext* context,
                                         css::uno::Sequence<css::uno::Any> const&)
 {
-    std::scoped_lock l(g_InstanceGuard);
-    if (g_Disposed)
-    {
-        return nullptr;
-    }
-    if (!g_Instance.is())
-    {
-        g_Instance.set(new CWinClipboard(context, ""));
-    }
-    return cppu::acquire(static_cast<cppu::OWeakObject*>(g_Instance.get()));
+    return cppu::acquire(static_cast<cppu::OWeakObject*>(new CWinClipboard(context, "")));
 }
 
 void CWinClipboard::onReleaseDataObject(CXNotifyingDataObject* theCaller)
@@ -358,11 +339,4 @@ void WINAPI CWinClipboard::onClipboardContentChanged()
     }
 }
 
-void CWinClipboard::disposing()
-{
-    std::scoped_lock l(g_InstanceGuard);
-    g_Instance.clear();
-    g_Disposed = true;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/dtrans/WinClipboard.hxx b/vcl/win/dtrans/WinClipboard.hxx
index 984a07a22dd7..1b0a05a3450d 100644
--- a/vcl/win/dtrans/WinClipboard.hxx
+++ b/vcl/win/dtrans/WinClipboard.hxx
@@ -82,8 +82,6 @@ class CWinClipboard final
 
     static void WINAPI onClipboardContentChanged();
 
-    void SAL_CALL disposing() override;
-
 public:
     CWinClipboard(const css::uno::Reference<css::uno::XComponentContext>& rxContext,
                   const OUString& aClipboardName);


More information about the Libreoffice-commits mailing list