svx/source/unodraw/unoshape.cxx |   45 ++++++++++------------------------------
 1 file changed, 12 insertions(+), 33 deletions(-)

New commits:
commit 5f891974bfb27bacd5fc3d623463204e872fffad
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Aug 25 21:03:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 26 09:07:00 2022 +0200

    simplify SvxShape::Notify a little
    
    (*) the logic at the bottom was very hard to read
    (*) by the time we hit the bottom of the method, we know pSdrObject
    cannot be nullptr
    
    Change-Id: I718d655f4e477bb3edaaa3f41412fb16c7336017
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138846
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index cb27ab065886..9eb3edfd5ab8 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -989,48 +989,27 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& 
rHint ) noexcept
         return;
     }
 
-    bool bClearMe = false;
-
-    switch( pSdrHint->GetKind() )
+    if (pSdrHint->GetKind() == SdrHintKind::ObjectChange)
     {
-        case SdrHintKind::ObjectChange:
-        {
-            updateShapeKind();
-            break;
-        }
-        case SdrHintKind::ModelCleared:
-        {
-            bClearMe = true;
-            break;
-        }
-        default:
-            break;
-    };
-
-    if( !bClearMe )
-        return;
-
-    if(!HasSdrObjectOwnership())
+        updateShapeKind();
+    }
+    else // (pSdrHint->GetKind() == SdrHintKind::ModelCleared)
     {
-        if(nullptr != pSdrObject)
+        if(!HasSdrObjectOwnership())
         {
             EndListening(pSdrObject->getSdrModelFromSdrObject());
             pSdrObject->setUnoShape(nullptr);
-        }
 
-        mpSdrObjectWeakReference.reset(nullptr);
+            mpSdrObjectWeakReference.reset(nullptr);
 
-        // SdrModel *is* going down, try to Free SdrObject even
-        // when !HasSdrObjectOwnership
-        if(nullptr != pSdrObject && !pSdrObject->IsInserted())
-        {
-            SdrObject::Free(pSdrObject);
+            // SdrModel *is* going down, try to Free SdrObject even
+            // when !HasSdrObjectOwnership
+            if(!pSdrObject->IsInserted())
+                SdrObject::Free(pSdrObject);
         }
-    }
 
-    if(!mpImpl->mbDisposing)
-    {
-        dispose();
+        if(!mpImpl->mbDisposing)
+            dispose();
     }
 }
 

Reply via email to