sfx2/source/doc/guisaveas.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
New commits: commit cdfed7bd0dc1124c925b3664ac5d9ff13c945121 Author: Xisco Fauli <[email protected]> AuthorDate: Mon Sep 1 14:04:52 2025 +0200 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Thu Sep 4 11:26:21 2025 +0200 sfx2: check SfxViewShell::Current() Seen in https://crashreport.libreoffice.org/stats/crash_details/4aabe4e5-c568-4fa8-bcbf-6fb787cd603a Regression after commit a4349c502eb2169b3f83d58e49a7871a341daf76 Author: Samuel Mehrbrodt <[email protected]> Date: Thu Aug 7 10:51:48 2025 +0200 tdf#167845 Don't preselect the template path Change-Id: If816b4d5aa8810028de682a79a2e37ac2855c250 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190477 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> Tested-by: Jenkins diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index b890ae226eb3..3f171cfd8bb8 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -960,9 +960,12 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode, // Fall back to the document base URL - but only if the document is not based on a template. // Otherwise the template's directory would be used, which is not what we want. - SfxObjectShell* pDocShell = SfxViewShell::Current()->GetObjectShell(); - if (sPreselectedDir.isEmpty() && pDocShell && !pDocShell->IsBasedOnTemplate()) - sPreselectedDir = GetDocProps().getUnpackedValueOrDefault("DocumentBaseURL", OUString()); + if (SfxViewShell* pViewShell = SfxViewShell::Current()) + { + SfxObjectShell* pDocShell = pViewShell->GetObjectShell(); + if (sPreselectedDir.isEmpty() && pDocShell && !pDocShell->IsBasedOnTemplate()) + sPreselectedDir = GetDocProps().getUnpackedValueOrDefault("DocumentBaseURL", OUString()); + } INetURLObject aObj(sPreselectedDir); aObj.removeSegment(); // remove file name from URL sPreselectedDir = aObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
