sd/source/ui/view/viewshel.cxx |   64 +++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 31 deletions(-)

New commits:
commit f4f20c7f56847f92273d782789d9b9fc50610bd6
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Oct 18 01:48:35 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Oct 18 12:48:34 2024 +0200

    tdf#163486: PVS: check GetView()
    
    V595    The 'GetView()' pointer was utilized before it was verified against 
nullptr. Check lines: 518, 531.
    
    Change-Id: I9c6ebccabece0923702e6a8fb4ee6beb9b6dc198
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175114
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins
    (cherry picked from commit a21b9064e89306404c467b354a1bbff20efbe6a3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175058
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 39423a4e082a..5e954c754cec 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -516,47 +516,49 @@ bool ViewShell::KeyInput(const KeyEvent& rKEvt, 
::sd::Window* pWin)
     OSL_ASSERT(GetViewShell() != nullptr);
     bReturn = GetViewShell()->KeyInput(rKEvt);
 
-    const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
-    const size_t OriCount = rMarkList.GetMarkCount();
-    if(!bReturn)
+    if (sd::View* pView = GetView())
     {
-        if(useInputForSlideShow()) //IASS
+        const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+        const size_t OriCount = rMarkList.GetMarkCount();
+        if(!bReturn)
         {
-            // use for SlideShow
-            rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( 
GetViewShellBase() ) );
-            bReturn = xSlideShow->keyInput(rKEvt);
-        }
-        else
-        {
-            bool bConsumed = false;
-            if( GetView() )
-                bConsumed = GetView()->getSmartTags().KeyInput(rKEvt);
-
-            if( !bConsumed )
+            if(useInputForSlideShow()) //IASS
             {
-                rtl::Reference< sdr::SelectionController > 
xSelectionController( GetView()->getSelectionController() );
-                if( !xSelectionController.is() || 
!xSelectionController->onKeyInput( rKEvt, pWin ) )
-                {
-                    if(HasCurrentFunction())
-                        bReturn = GetCurrentFunction()->KeyInput(rKEvt);
-                }
-                else
+                // use for SlideShow
+                rtl::Reference< SlideShow > xSlideShow( 
SlideShow::GetSlideShow( GetViewShellBase() ) );
+                bReturn = xSlideShow->keyInput(rKEvt);
+            }
+            else
+            {
+                bool bConsumed = false;
+                bConsumed = pView->getSmartTags().KeyInput(rKEvt);
+
+                if( !bConsumed )
                 {
-                    bReturn = true;
-                    if (HasCurrentFunction())
+                    rtl::Reference< sdr::SelectionController > 
xSelectionController( pView->getSelectionController() );
+                    if( !xSelectionController.is() || 
!xSelectionController->onKeyInput( rKEvt, pWin ) )
                     {
-                        FuText* pTextFunction = 
dynamic_cast<FuText*>(GetCurrentFunction().get());
-                        if(pTextFunction != nullptr)
-                            pTextFunction->InvalidateBindings();
+                        if(HasCurrentFunction())
+                            bReturn = GetCurrentFunction()->KeyInput(rKEvt);
+                    }
+                    else
+                    {
+                        bReturn = true;
+                        if (HasCurrentFunction())
+                        {
+                            FuText* pTextFunction = 
dynamic_cast<FuText*>(GetCurrentFunction().get());
+                            if(pTextFunction != nullptr)
+                                pTextFunction->InvalidateBindings();
+                        }
                     }
                 }
             }
         }
+        const size_t EndCount = rMarkList.GetMarkCount();
+        // Here, oriCount or endCount must have one value=0, another value > 
0, then to switch focus between Document and shape objects
+        if(bReturn &&  (OriCount + EndCount > 0) && (OriCount * EndCount == 0))
+            SwitchActiveViewFireFocus();
     }
-    const size_t EndCount = rMarkList.GetMarkCount();
-    // Here, oriCount or endCount must have one value=0, another value > 0, 
then to switch focus between Document and shape objects
-    if(bReturn &&  (OriCount + EndCount > 0) && (OriCount * EndCount == 0))
-        SwitchActiveViewFireFocus();
 
     if(!bReturn && GetActiveWindow())
     {

Reply via email to