sw/source/uibase/utlui/navipi.cxx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
New commits: commit 084882a66c4e612f207024be301631102be31ca6 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Thu Apr 25 10:12:41 2024 +0200 Commit: Vasily Melenchuk <vasily.melenc...@cib.de> CommitDate: Mon Apr 29 12:06:00 2024 +0200 sw: fixed crash on GetCreateView() returning nullptr Change-Id: Id0cb44ac7d805a1736fa8170aaffb97b54211707 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166617 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de> diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index bb8338e3fe9e..e86e51c30d11 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -73,6 +73,8 @@ OUString SwNavigationPI::CleanEntry(const OUString& rEntry) void SwNavigationPI::MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget) { SwView *pView = GetCreateView(); + if (!pView) + return; SwWrtShell &rSh = pView->GetWrtShell(); if(nTarget < nSource || nTarget == SwOutlineNodes::npos) nTarget ++; @@ -575,7 +577,7 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent, //Open Headings by default SwView *pView = GetCreateView(); - if (pView->m_nNaviExpandedStatus < 0) + if (pView && pView->m_nNaviExpandedStatus < 0) { pView->m_nNaviExpandedStatus = 1; m_xContentTree->ExpandAllHeadings(); @@ -684,13 +686,16 @@ void SwNavigationPI::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState /*eState*/, if (SwView::GetMoveType() == NID_PGE) { SwView *pView = GetCreateView(); - SwWrtShell &rSh = pView->GetWrtShell(); - // GetPageNum - return current page number: - // true: in which cursor is located. - // false: which is visible at the upper margin. - sal_uInt16 nPhyNum, nVirtNum; - rSh.GetPageNum(nPhyNum, nVirtNum, false); - m_xGotoPageSpinButton->set_text(OUString::number(nPhyNum)); + if (pView) + { + SwWrtShell& rSh = pView->GetWrtShell(); + // GetPageNum - return current page number: + // true: in which cursor is located. + // false: which is visible at the upper margin. + sal_uInt16 nPhyNum, nVirtNum; + rSh.GetPageNum(nPhyNum, nVirtNum, false); + m_xGotoPageSpinButton->set_text(OUString::number(nPhyNum)); + } } } }