include/sfx2/bindings.hxx        |    3 ++-
 sfx2/source/control/bindings.cxx |   14 +++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit c94d45cd08e2d5db5c007b9a77352f7621f84a09
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jul 1 10:11:40 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jul 1 14:24:44 2021 +0200

    can pass this SfxItemSet around on the stack
    
    Change-Id: Ie2e67ec19cfacdfdd0a6dd85c464cfa326b6500d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118209
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx
index f4f44bd1af7a..47b904d6d113 100644
--- a/include/sfx2/bindings.hxx
+++ b/include/sfx2/bindings.hxx
@@ -23,6 +23,7 @@
 
 #include <cstddef>
 #include <memory>
+#include <optional>
 
 #include <o3tl/typed_flags_set.hxx>
 #include <sfx2/dllapi.h>
@@ -101,7 +102,7 @@ private:
                                     SfxCallMode nCall, const SfxPoolItem 
**pInternalArgs, bool bGlobalOnly=false);
     SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* );
     SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // Update SlotServer
-    SAL_DLLPRIVATE std::unique_ptr<SfxItemSet> CreateSet_Impl(SfxStateCache& 
rCache, const SfxSlot* &pRealSlot,
+    SAL_DLLPRIVATE std::optional<SfxItemSet> CreateSet_Impl(SfxStateCache& 
rCache, const SfxSlot* &pRealSlot,
                                               const SfxSlotServer**, 
SfxFoundCacheArr_Impl&);
     SAL_DLLPRIVATE std::size_t GetSlotPos( sal_uInt16 nId, std::size_t 
nStartSearchAt = 0 );
     SAL_DLLPRIVATE void Update_Impl(SfxStateCache& rCache);
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index b75d0dbcae02..ca8366f26539 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -252,7 +252,7 @@ void SfxBindings::Update_Impl(SfxStateCache& rCache /*The 
up to date SfxStatusCa
     const SfxSlot *pRealSlot = nullptr;
     const SfxSlotServer* pMsgServer = nullptr;
     SfxFoundCacheArr_Impl aFound;
-    std::unique_ptr<SfxItemSet> pSet = CreateSet_Impl(rCache, pRealSlot, 
&pMsgServer, aFound);
+    std::optional<SfxItemSet> pSet = CreateSet_Impl(rCache, pRealSlot, 
&pMsgServer, aFound);
     bool bUpdated = false;
     if ( pSet )
     {
@@ -1090,7 +1090,7 @@ void SfxBindings::UpdateSlotServer_Impl()
 }
 
 
-std::unique_ptr<SfxItemSet> SfxBindings::CreateSet_Impl
+std::optional<SfxItemSet> SfxBindings::CreateSet_Impl
 (
     SfxStateCache&          rCache,     // in: Status-Cache from nId
     const SfxSlot*&         pRealSlot,  // out: RealSlot to nId
@@ -1103,7 +1103,7 @@ std::unique_ptr<SfxItemSet> SfxBindings::CreateSet_Impl
 
     const SfxSlotServer* pMsgSvr = rCache.GetSlotServer(*pDispatcher, 
pImpl->xProv);
     if (!pMsgSvr)
-        return nullptr;
+        return {};
 
     pRealSlot = nullptr;
     *pMsgServer = pMsgSvr;
@@ -1111,7 +1111,7 @@ std::unique_ptr<SfxItemSet> SfxBindings::CreateSet_Impl
     sal_uInt16 nShellLevel = pMsgSvr->GetShellLevel();
     SfxShell *pShell = pDispatcher->GetShell( nShellLevel );
     if ( !pShell ) // rare GPF when browsing through update from Inet-Notify
-        return nullptr;
+        return {};
 
     SfxItemPool &rPool = pShell->GetPool();
 
@@ -1167,7 +1167,7 @@ std::unique_ptr<SfxItemSet> SfxBindings::CreateSet_Impl
 
     // Create a Set from the ranges
     size_t i = 0;
-    auto pSet(std::make_unique<SfxItemSet>(rPool, nullptr));
+    SfxItemSet aSet(rPool, nullptr);
     while ( i < rFound.size() )
     {
         const sal_uInt16 nWhich1 = rFound[i].nWhichId;
@@ -1176,9 +1176,9 @@ std::unique_ptr<SfxItemSet> SfxBindings::CreateSet_Impl
             if ( rFound[i].nWhichId+1 != rFound[i+1].nWhichId )
                 break;
         const sal_uInt16 nWhich2 = rFound[i++].nWhichId;
-        pSet->MergeRange(nWhich1, nWhich2);
+        aSet.MergeRange(nWhich1, nWhich2);
     }
-    return pSet;
+    return aSet;
 }
 
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to