diff options
author | Jim Raykowski <raykowj@gmail..com> | 2020-02-24 23:43:52 -0900 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2020-02-25 19:12:06 +0100 |
commit | 6d23f2667edc9f8b867066a432dff152f8427ce0 (patch) | |
tree | fe096e123540db0bd0f18232fcd5279343075555 /sw/source/uibase/utlui | |
parent | 9bb7f05793e208f6340a6bdac9e38d63d447552a (diff) |
tdf#128814 follow up: check for nullptr and dispose unused sub pop menu
Prevent nullptr crash in lcl_IsContent and dispose and clear sub pop
outline tracking menu if unused.
Change-Id: I6d3e1a48776426ae18156cc70b799f74f349bf5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89410
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sw/source/uibase/utlui')
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index d0b1934aa1d8..f70f72815075 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1287,15 +1287,15 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu() else if (State::HIDDEN == m_eState) pSubPop3->CheckItem( nId ); - SvTreeListEntry* pEntry = nullptr; - if (lcl_IsContent(FirstSelected())) + SvTreeListEntry* pEntry = FirstSelected(); + if (pEntry && lcl_IsContent(pEntry)) { pPop->InsertItem(900, SwResId(STR_GOTO)); pPop->SetAccelKey(900, vcl::KeyCode(KEY_RETURN, false, false, false, false)); } // Edit only if the shown content is coming from the current view. if ((State::ACTIVE == m_eState || m_pActiveShell == pActiveView->GetWrtShellPtr()) - && nullptr != (pEntry = FirstSelected()) && lcl_IsContent(pEntry)) + && pEntry && lcl_IsContent(pEntry)) { assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()))); const SwContentType* pContType = static_cast<SwContent*>(pEntry->GetUserData())->GetParent(); @@ -1425,7 +1425,10 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu() pPop->SetPopupMenu(1, pSubPop1); } else + { + pSubPopOutlineTracking.disposeAndClear(); pSubPop1.disposeAndClear(); + } pPop->InsertItem(2, m_aContextStrings[IDX_STR_DRAGMODE]); pPop->SetPopupMenu(2, pSubPop2); pPop->InsertItem(3, m_aContextStrings[IDX_STR_DISPLAY]); |