summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2020-07-16 13:25:47 -0800
committerXisco Fauli <xiscofauli@libreoffice.org>2020-08-10 11:31:25 +0200
commit41e180f500a42a3afd53b673f538becd75a8f120 (patch)
tree664e7f3b13016e15ad3cbf5b0564876bf87880f8 /sd
parent82ab191a074141aafa7567fc3c3cad9bc7ea0b24 (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> (cherry picked from commit f52f86a3905fc099832187ad20fd29f0ab73b43f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100226 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/sidebar/DocumentHelper.cxx5
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)