starmath/source/cursor.cxx   |    4 ++--
 starmath/source/dialog.cxx   |    7 +++++--
 starmath/source/document.cxx |    8 +++-----
 3 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit c0181b2f26b784d8317f51a77a9dfade16913ad1
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Feb 17 15:50:29 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Feb 20 11:25:56 2023 +0000

    check SmGetActiveView()
    
    it might be null
    
    See 
https://crashreport.libreoffice.org/stats/signature/SmPrintOptionsTabPage::~SmPrintOptionsTabPage()
    
    Change-Id: I7bc17da230784e6e3fc9c0b33848423ac113ab29
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147221
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit a7fd1e067eb2af0ef329719c4c7dbb32cc5926b2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147246
    (cherry picked from commit b905b793be520b9fdece8d12614566be82ce3c92)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147312
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 52621d360c80..d5479ab42765 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1315,8 +1315,8 @@ void SmCursor::EndEdit(){
 }
 
 void SmCursor::RequestRepaint(){
-    SmViewShell *pViewSh = SmGetActiveView();
-    if( pViewSh ) {
+    if (SmViewShell *pViewSh = SmGetActiveView())
+    {
         if ( SfxObjectCreateMode::EMBEDDED == mpDocShell->GetCreateMode() )
             mpDocShell->Repaint();
         else
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 043739cf5c0d..19992b341c36 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -181,7 +181,8 @@ 
SmPrintOptionsTabPage::SmPrintOptionsTabPage(weld::Container* pPage, weld::Dialo
 
 SmPrintOptionsTabPage::~SmPrintOptionsTabPage()
 {
-    SmGetActiveView()->GetEditWindow()->UpdateStatus();
+    if (SmViewShell *pViewSh = SmGetActiveView())
+        pViewSh->GetEditWindow()->UpdateStatus();
 }
 
 bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
@@ -204,7 +205,9 @@ bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
     rSet->Put(SfxBoolItem(SID_AUTO_CLOSE_BRACKETS, 
m_xAutoCloseBrackets->get_active()));
     rSet->Put(SfxUInt16Item(SID_SMEDITWINDOWZOOM, 
sal::static_int_cast<sal_uInt16>(m_xSmZoom->get_value(FieldUnit::PERCENT))));
 
-    SmGetActiveView()->GetEditWindow()->UpdateStatus();
+    if (SmViewShell *pViewSh = SmGetActiveView())
+        pViewSh->GetEditWindow()->UpdateStatus();
+
     return true;
 }
 
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 23034ede3e3c..59353879d4e4 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -159,7 +159,7 @@ void SmDocShell::SetText(const OUString& rBuffer)
     Parse();
 
     SmViewShell *pViewSh = SmGetActiveView();
-    if( pViewSh )
+    if (pViewSh)
     {
         pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
         if ( SfxObjectCreateMode::EMBEDDED == GetCreateMode() )
@@ -256,8 +256,7 @@ void SmDocShell::ArrangeFormula()
     // if necessary get another OutputDevice for which we format
     if (!pOutDev)
     {
-        SmViewShell *pView = SmGetActiveView();
-        if (pView)
+        if (SmViewShell *pView = SmGetActiveView())
             pOutDev = 
&pView->GetGraphicWidget().GetDrawingArea()->get_ref_device();
         else
         {
@@ -542,8 +541,7 @@ void SmDocShell::Repaint()
 
     Size aVisSize = GetSize();
     SetVisAreaSize(aVisSize);
-    SmViewShell* pViewSh = SmGetActiveView();
-    if (pViewSh)
+    if (SmViewShell* pViewSh = SmGetActiveView())
         pViewSh->GetGraphicWidget().Invalidate();
 
     if (bIsEnabled)

Reply via email to