sw/source/core/attr/format.cxx |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit f505d8fee149f089090b208db99a7b4107af76e9
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Fri Aug 19 16:33:21 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 19 18:35:29 2022 +0200

    unique_ptr->optional in SwFormat::SwClientNotify
    
    Change-Id: I9ac4a1c538fd45a7002f618966494b43245cb3c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138554
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 3f9aa8f85f7f..4f458edb8712 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -229,8 +229,8 @@ void SwFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
 
-    std::unique_ptr<SwAttrSetChg> pOldClientChg, pNewClientChg;
-    auto pDependsHint = 
std::make_unique<sw::LegacyModifyHint>(pLegacy->m_pOld, pLegacy->m_pNew);
+    std::optional<SwAttrSetChg> oOldClientChg, oNewClientChg;
+    std::optional<sw::LegacyModifyHint> oDependsHint(std::in_place, 
pLegacy->m_pOld, pLegacy->m_pNew);
     const sal_uInt16 nWhich = pLegacy->GetWhich();
     InvalidateInSwCache(nWhich);
     switch(nWhich)
@@ -272,16 +272,16 @@ void SwFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
             if (pOldAttrSetChg && pNewAttrSetChg && 
pOldAttrSetChg->GetTheChgdSet() != &m_aSet)
             {
                 // pass only those that are not set...
-                pNewClientChg.reset(new SwAttrSetChg(*pNewAttrSetChg));
-                pNewClientChg->GetChgSet()->Differentiate(m_aSet);
-                if(pNewClientChg->Count()) // ... if any
+                oNewClientChg.emplace(*pNewAttrSetChg);
+                oNewClientChg->GetChgSet()->Differentiate(m_aSet);
+                if(oNewClientChg->Count()) // ... if any
                 {
-                    pOldClientChg.reset(new SwAttrSetChg(*pOldAttrSetChg));
-                    pOldClientChg->GetChgSet()->Differentiate(m_aSet);
-                    pDependsHint.reset(new 
sw::LegacyModifyHint(pOldClientChg.get(), pNewClientChg.get()));
+                    oOldClientChg.emplace(*pOldAttrSetChg);
+                    oOldClientChg->GetChgSet()->Differentiate(m_aSet);
+                    oDependsHint.emplace(&*oOldClientChg, &*oNewClientChg);
                 }
                 else
-                    pDependsHint.reset(nullptr);
+                    oDependsHint.reset();
             }
             break;
         }
@@ -307,13 +307,13 @@ void SwFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
             {
                 // DropCaps might come into this block
                 SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was 
sent without sender");
-                pDependsHint.reset(nullptr);
+                oDependsHint.reset();
             }
     }
-    if(pDependsHint)
+    if(oDependsHint)
     {
-        InvalidateInSwFntCache(pDependsHint->GetWhich());
-        SwModify::SwClientNotify(*this, *pDependsHint);
+        InvalidateInSwFntCache(oDependsHint->GetWhich());
+        SwModify::SwClientNotify(*this, *oDependsHint);
     }
 }
 

Reply via email to