diff options
author | Jim Raykowski <raykowj@gmail.com> | 2020-07-16 13:25:47 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2020-08-07 06:29:09 +0200 |
commit | f52f86a3905fc099832187ad20fd29f0ab73b43f (patch) | |
tree | 1d01a52c90f10651110f00800a7f187a26690cc4 /sd | |
parent | 703809e1c9451ecf488b8fba09ed0c72d9468bbd (diff) |
tdf#134847 fix nullptr use crash
Grabbing focus back to the document when OLE object last had focus sets
focus to the frame containing the OLE object. sd::ViewShell is no good
in this case and crashes when undo manager tries to pass ViewShellId to
EnterListAction. Other areas in the code set ViewShellId(-1) and then
check if ViewShell is good before getting ViewShellId. This patch
follows these practices.
Change-Id: I89093686c4d98148ac032832711f80479366741d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99759
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/sidebar/DocumentHelper.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx index 151cc510622e..08fab9f247d3 100644 --- a/sd/source/ui/sidebar/DocumentHelper.cxx +++ b/sd/source/ui/sidebar/DocumentHelper.cxx @@ -312,9 +312,12 @@ void DocumentHelper::AssignMasterPageToPageList ( if (aCleanedList.empty() ) return; + ViewShellId nViewShellId(-1); + if (sd::ViewShell* pViewShell = rTargetDocument.GetDocSh()->GetViewShell()) + nViewShellId = pViewShell->GetViewShellBase().GetViewShellId(); SfxUndoManager* pUndoMgr = rTargetDocument.GetDocSh()->GetUndoManager(); if( pUndoMgr ) - pUndoMgr->EnterListAction(SdResId(STR_UNDO_SET_PRESLAYOUT), OUString(), 0, rTargetDocument.GetDocSh()->GetViewShell()->GetViewShellBase().GetViewShellId()); + pUndoMgr->EnterListAction(SdResId(STR_UNDO_SET_PRESLAYOUT), OUString(), 0, nViewShellId); SdPage* pMasterPageInDocument = ProvideMasterPage(rTargetDocument,pMasterPage,rpPageList); if (pMasterPageInDocument == nullptr) |