sd/source/ui/inc/ViewShellBase.hxx       |    2 +-
 sd/source/ui/table/TableDesignPane.cxx   |   14 +++++++++-----
 sd/source/ui/view/ViewShellBase.cxx      |    4 ++--
 sd/source/ui/view/viewoverlaymanager.cxx |   10 ++++++----
 4 files changed, 18 insertions(+), 12 deletions(-)

New commits:
commit b81ff51a8ccac942effdd309f014591604376ecc
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon May 27 20:04:31 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue May 28 11:18:02 2024 +0200

    sd: use SAL_RET_MAYBENULL in GetDrawView()
    
    Directly return nullptr instead of calling SfxViewShell::GetDrawView()
    which return nullptr to make it obvious
    
    Change-Id: I5e81d23f541a73181bb6f7d9e7f1d6ec56ff57ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168116
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/source/ui/inc/ViewShellBase.hxx 
b/sd/source/ui/inc/ViewShellBase.hxx
index cdec6d8a6b02..1e1517eb6550 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -153,7 +153,7 @@ public:
     virtual bool PrepareClose (bool bUI = true) override;
     virtual void WriteUserData (OUString&, bool bBrowse = false) override;
     virtual void ReadUserData (const OUString&, bool bBrowse = false) override;
-    virtual SdrView* GetDrawView() const override;
+    SAL_RET_MAYBENULL virtual SdrView* GetDrawView() const override;
 
     /** When <TRUE/> is given, then the mouse shape is set to hour glass (or
         whatever the busy shape looks like on the system.)
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index bf125e126b0d..3672f5655bf6 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -816,8 +816,8 @@ SdrView* ViewShellBase::GetDrawView() const
     ViewShell* pShell = GetMainViewShell().get();
     if (pShell != nullptr)
         return pShell->GetDrawView ();
-    else
-        return SfxViewShell::GetDrawView();
+
+    return nullptr;
 }
 
 void ViewShellBase::SetBusyState (bool bBusy)
commit f60fd89e3d4ee60d9b9d0a02ed96c36ff8667188
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon May 27 22:12:38 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue May 28 11:17:56 2024 +0200

    sd: warning C6011: Dereferencing NULL pointer
    
    Change-Id: Id073e5d340fc91836b4689fb3e7a558ef3263e56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168119
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/source/ui/table/TableDesignPane.cxx 
b/sd/source/ui/table/TableDesignPane.cxx
index 1b9262d954e3..54797bb3894c 100644
--- a/sd/source/ui/table/TableDesignPane.cxx
+++ b/sd/source/ui/table/TableDesignPane.cxx
@@ -379,9 +379,13 @@ void TableDesignWidget::EditStyle(const OUString& rCommand)
         aBoxInfoItem.SetTable(false);
         aNewAttr.Put(aBoxInfoItem);
 
+        SdrView* pDrawView = mrBase.GetDrawView();
+        if (!pDrawView)
+            return;
+
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact ? 
pFact->CreateSvxFormatCellsDialog(
-            mrBase.GetFrameWeld(), aNewAttr, mrBase.GetDrawView()->GetModel(), 
true) : nullptr);
+            mrBase.GetFrameWeld(), aNewAttr, pDrawView->GetModel(), true) : 
nullptr);
         if (pDlg && pDlg->Execute() == RET_OK)
         {
             endTextEditForStyle(xTableStyle);
@@ -452,10 +456,9 @@ void TableDesignWidget::ApplyStyle()
         if( sStyleName.isEmpty() )
             return;
 
-        SdrView* pView = mrBase.GetDrawView();
         if( mxSelectedTable.is() )
         {
-            if( pView )
+            if (SdrView* pView = mrBase.GetDrawView())
             {
                 if (pView->IsTextEdit())
                     pView->SdrEndTextEdit();
@@ -693,8 +696,9 @@ void TableDesignWidget::endTextEditForStyle(const 
Reference<XInterface>& rStyle)
     if (xTableStyle != rStyle)
         return;
 
-    if (mrBase.GetDrawView()->IsTextEdit())
-        mrBase.GetDrawView()->SdrEndTextEdit();
+    SdrView* pDrawView = mrBase.GetDrawView();
+    if (pDrawView && pDrawView->IsTextEdit())
+        pDrawView->SdrEndTextEdit();
 }
 
 void TableDesignWidget::addListener()
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx 
b/sd/source/ui/view/viewoverlaymanager.cxx
index bd2e6be970f8..dfc6c61759fc 100644
--- a/sd/source/ui/view/viewoverlaymanager.cxx
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -479,8 +479,9 @@ IMPL_LINK_NOARG(ViewOverlayManager, UpdateTagsHdl, void*, 
void)
     bool bChanges = DisposeTags();
     bChanges |= CreateTags();
 
-    if( bChanges && mrBase.GetDrawView() )
-        static_cast< ::sd::View* >( mrBase.GetDrawView() )->updateHandles();
+    SdrView* pDrawView = mrBase.GetDrawView();
+    if( bChanges && pDrawView )
+        static_cast< ::sd::View* >( pDrawView )->updateHandles();
 }
 
 bool ViewOverlayManager::CreateTags()
@@ -490,14 +491,15 @@ bool ViewOverlayManager::CreateTags()
     std::shared_ptr<ViewShell> aMainShell = mrBase.GetMainViewShell();
 
     SdPage* pPage = aMainShell ? aMainShell->getCurrentPage() : nullptr;
+    SdrView* pDrawView = mrBase.GetDrawView();
 
-    if( pPage && !pPage->IsMasterPage() && (pPage->GetPageKind() == 
PageKind::Standard) )
+    if( pDrawView && pPage && !pPage->IsMasterPage() && (pPage->GetPageKind() 
== PageKind::Standard) )
     {
         const std::list< SdrObject* >& rShapes = 
pPage->GetPresentationShapeList().getList();
 
         for( SdrObject* pShape : rShapes )
         {
-            if( pShape->IsEmptyPresObj() && (pShape->GetObjIdentifier() == 
SdrObjKind::OutlineText) && (mrBase.GetDrawView()->GetTextEditObject() != 
pShape) )
+            if( pShape->IsEmptyPresObj() && (pShape->GetObjIdentifier() == 
SdrObjKind::OutlineText) && (pDrawView->GetTextEditObject() != pShape) )
             {
                 rtl::Reference< SmartTag > xTag( new ChangePlaceholderTag( 
*mrBase.GetMainViewShell()->GetView(), *pShape ) );
                 maTagVector.push_back(xTag);

Reply via email to