Blame SOURCES/0002-gnome-documents-rework-SfxPickList-as-pimpl.patch

69cc7b
From 24785875d0bbeae58fe362b088238115c961e2c1 Mon Sep 17 00:00:00 2001
69cc7b
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
69cc7b
Date: Mon, 8 May 2017 15:35:29 +0100
69cc7b
Subject: [PATCH 2/5] gnome-documents: rework SfxPickList as pimpl
69cc7b
MIME-Version: 1.0
69cc7b
Content-Type: text/plain; charset=UTF-8
69cc7b
Content-Transfer-Encoding: 8bit
69cc7b
69cc7b
and call impl dtor with SolarMutex held
69cc7b
69cc7b
Change-Id: I06931ca9ab4384a5e3c255847cf3533ed03b77dc
69cc7b
Reviewed-on: https://gerrit.libreoffice.org/37395
69cc7b
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
69cc7b
Tested-by: Caolán McNamara <caolanm@redhat.com>
69cc7b
(cherry picked from commit 53082fcd1b1cccf7ef0c3cb1bef8e747c4e88a61)
69cc7b
---
69cc7b
 sfx2/source/appl/sfxpicklist.cxx | 40 ++++++++++++++++++++++++++++++++--------
69cc7b
 sfx2/source/inc/sfxpicklist.hxx  | 27 +++++++++------------------
69cc7b
 2 files changed, 41 insertions(+), 26 deletions(-)
69cc7b
69cc7b
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
69cc7b
index cc3a5cf..7781e9d 100644
69cc7b
--- a/sfx2/source/appl/sfxpicklist.cxx
69cc7b
+++ b/sfx2/source/appl/sfxpicklist.cxx
69cc7b
@@ -83,7 +83,25 @@ namespace
69cc7b
         : public rtl::Static<osl::Mutex, thePickListMutex> {};
69cc7b
 }
69cc7b
 
69cc7b
-void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
69cc7b
+class SfxPickListImpl : public SfxListener
69cc7b
+{
69cc7b
+private:
69cc7b
+    sal_uInt32 m_nAllowedMenuSize;
69cc7b
+    css::uno::Reference< css::util::XStringWidth > m_xStringLength;
69cc7b
+
69cc7b
+    /**
69cc7b
+     * Adds the given document to the pick list (recent documents) if it satisfies
69cc7b
+       certain requirements, e.g. being writable. Check implementation for requirement
69cc7b
+       details.
69cc7b
+     */
69cc7b
+    static void         AddDocumentToPickList( SfxObjectShell* pDocShell );
69cc7b
+
69cc7b
+public:
69cc7b
+    SfxPickListImpl(sal_uInt32 nMenuSize);
69cc7b
+    virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
69cc7b
+};
69cc7b
+
69cc7b
+void SfxPickListImpl::AddDocumentToPickList( SfxObjectShell* pDocSh )
69cc7b
 {
69cc7b
     if (pDocSh->IsAvoidRecentDocs() || comphelper::LibreOfficeKit::isActive())
69cc7b
         return;
69cc7b
@@ -167,12 +185,23 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
69cc7b
                                                                  (pFilter) ? pFilter->GetServiceName() : OUString() );
69cc7b
 }
69cc7b
 
69cc7b
+SfxPickList::SfxPickList(sal_uInt32 nAllowedMenuSize)
69cc7b
+    : mxImpl(new SfxPickListImpl(nAllowedMenuSize))
69cc7b
+{
69cc7b
+}
69cc7b
+
69cc7b
+SfxPickList::~SfxPickList()
69cc7b
+{
69cc7b
+    std::unique_ptr<SolarMutexGuard> xGuard(comphelper::SolarMutex::get() ? new SolarMutexGuard : nullptr);
69cc7b
+    mxImpl.reset();
69cc7b
+}
69cc7b
+
69cc7b
 void SfxPickList::ensure()
69cc7b
 {
69cc7b
     static SfxPickList aUniqueInstance(SvtHistoryOptions().GetSize(ePICKLIST));
69cc7b
 }
69cc7b
 
69cc7b
-SfxPickList::SfxPickList( sal_uInt32 nAllowedMenuSize ) :
69cc7b
+SfxPickListImpl::SfxPickListImpl( sal_uInt32 nAllowedMenuSize ) :
69cc7b
     m_nAllowedMenuSize( nAllowedMenuSize )
69cc7b
 {
69cc7b
     m_xStringLength = new StringLength;
69cc7b
@@ -180,12 +209,7 @@ SfxPickList::SfxPickList( sal_uInt32 nAllowedMenuSize ) :
69cc7b
     StartListening( *SfxGetpApp() );
69cc7b
 }
69cc7b
 
69cc7b
-SfxPickList::~SfxPickList()
69cc7b
-{
69cc7b
-}
69cc7b
-
69cc7b
-
69cc7b
-void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint )
69cc7b
+void SfxPickListImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
69cc7b
 {
69cc7b
     const SfxOpenUrlHint* pOpenUrlHint = dynamic_cast<const SfxOpenUrlHint*>(&rHint);
69cc7b
     if ( pOpenUrlHint )
69cc7b
diff --git a/sfx2/source/inc/sfxpicklist.hxx b/sfx2/source/inc/sfxpicklist.hxx
69cc7b
index b1e86b0..cf257d9 100644
69cc7b
--- a/sfx2/source/inc/sfxpicklist.hxx
69cc7b
+++ b/sfx2/source/inc/sfxpicklist.hxx
69cc7b
@@ -29,25 +29,16 @@
69cc7b
 
69cc7b
 #define PICKLIST_MAXSIZE  100
69cc7b
 
69cc7b
-class SfxPickList : public SfxListener
69cc7b
-{
69cc7b
-    sal_uInt32                      m_nAllowedMenuSize;
69cc7b
-    css::uno::Reference< css::util::XStringWidth > m_xStringLength;
69cc7b
-
69cc7b
-                            SfxPickList( sal_uInt32 nMenuSize );
69cc7b
-                            virtual ~SfxPickList() override;
69cc7b
-
69cc7b
-    /**
69cc7b
-     * Adds the given document to the pick list (recent documents) if it satisfies
69cc7b
-       certain requirements, e.g. being writable. Check implementation for requirement
69cc7b
-       details.
69cc7b
-     */
69cc7b
-    static void             AddDocumentToPickList( SfxObjectShell* pDocShell );
69cc7b
+class SfxPickListImpl;
69cc7b
 
69cc7b
-    public:
69cc7b
-        static void ensure();
69cc7b
-
69cc7b
-        virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
69cc7b
+class SfxPickList
69cc7b
+{
69cc7b
+private:
69cc7b
+    std::unique_ptr<SfxPickListImpl> mxImpl;
69cc7b
+public:
69cc7b
+    SfxPickList(sal_uInt32 nAllowedMenuSize);
69cc7b
+    static void ensure();
69cc7b
+    ~SfxPickList();
69cc7b
 };
69cc7b
 
69cc7b
 #endif // INCLUDED_SFX2_SOURCE_INC_SFXPICKLIST_HXX
69cc7b
-- 
69cc7b
2.9.3
69cc7b