sc/source/ui/undo/undotab.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
New commits: commit b26918017337717f1ba9b651773aefa2e644e542 Author: Caolán McNamara <[email protected]> AuthorDate: Fri May 24 19:28:25 2024 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed May 29 23:07:48 2024 +0200 cid#1598442 Dereference null return value Change-Id: Id44fb940ba17549068c5be554d5738ce81ced79a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168028 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit 50c718557da8d3141377a10a4a944736111a1494) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168193 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 0eacb70d1c9c..d18579c59ec1 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -391,6 +391,9 @@ void ScUndoDeleteTab::Undo() void ScUndoDeleteTab::Redo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + pViewShell->SetTabNo( lcl_GetVisibleTabBefore( pDocShell->GetDocument(), theTabs.front() ) ); RedoSdrUndoAction( pDrawUndo.get() ); // Draw Redo first @@ -903,16 +906,13 @@ void ScUndoImportTab::DoChange() const ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nTabCount = rDoc.GetTableCount(); - if (pViewShell) + if(nTab<nTabCount) { - if(nTab<nTabCount) - { - pViewShell->SetTabNo(nTab,true); - } - else - { - pViewShell->SetTabNo(nTab-1,true); - } + pViewShell->SetTabNo(nTab,true); + } + else + { + pViewShell->SetTabNo(nTab-1,true); } SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); // Navigator @@ -1131,8 +1131,7 @@ void ScUndoShowHideTab::DoChange( bool bShowP ) const for(const SCTAB& nTab : undoTabs) { rDoc.SetVisible( nTab, bShowP ); - if (pViewShell) - pViewShell->SetTabNo(nTab,true); + pViewShell->SetTabNo(nTab,true); } SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
