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

New commits:
commit b905b793be520b9fdece8d12614566be82ce3c92
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Feb 17 15:50:29 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Feb 20 09:03:43 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

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index c7c27616b3f9..e8623517bcd7 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1330,9 +1330,10 @@ void SmCursor::EndEdit(){
     mpDocShell->GetEditEngine().QuickFormatDoc();
 }
 
-void SmCursor::RequestRepaint(){
-    SmViewShell *pViewSh = SmGetActiveView();
-    if( pViewSh ) {
+void SmCursor::RequestRepaint()
+{
+    if (SmViewShell *pViewSh = SmGetActiveView())
+    {
         if (comphelper::LibreOfficeKit::isActive())
         {
             pViewSh->SendCaretToLOK();
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 2aedbae19d05..e7450727ad61 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 e7c5dee90c4d..0593d26c268c 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -150,7 +150,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() )
@@ -247,8 +247,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
         {
@@ -533,8 +532,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