diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-16 12:11:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-16 21:17:15 +0000 |
commit | 1726c27e0d633ab04843834d2bf987bc7645807f (patch) | |
tree | 7810a18cd5bc3bf5aa345b816b372d93bd323974 /desktop | |
parent | 1ae71d8f09771ba7180be6ebdf89d36a31eb8625 (diff) |
check SfxObjectShell::Current()
SfxObjectShell::Current() can return null, it's based on the equally
vile SfxViewFrame::Current()
Change-Id: Ia5c7783680e9d8e5d3075078f16a2c15cb6f7a47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144339
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 22efa304865a..cdf6049d193d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1232,6 +1232,8 @@ rtl::Reference<LOKClipboard> forceSetClipboardForCurrentView(LibreOfficeKitDocum const vcl::Font* FindFont(std::u16string_view rFontName) { SfxObjectShell* pDocSh = SfxObjectShell::Current(); + if (!pDocSh) + return nullptr; const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST)); const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr; @@ -4580,7 +4582,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma { // Check if saving a PDF file OUString aMimeType = lcl_getCurrentDocumentMimeType(pDocument); - if (pDocSh->IsModified() && aMimeType == "application/pdf") + if (pDocSh && pDocSh->IsModified() && aMimeType == "application/pdf") { // If we have a PDF file (for saving annotations for example), we need // to run save-as to the same file as the opened document. Plain save @@ -4621,7 +4623,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma }), aPropertyValuesVector.end()); // skip saving and tell the result via UNO_COMMAND_RESULT - if (bDontSaveIfUnmodified && !pDocSh->IsModified()) + if (bDontSaveIfUnmodified && (!pDocSh || !pDocSh->IsModified())) { tools::JsonWriter aJson; aJson.put("commandName", pCommand); @@ -5393,6 +5395,8 @@ static char* getLanguages(const char* pCommand) static char* getFonts (const char* pCommand) { SfxObjectShell* pDocSh = SfxObjectShell::Current(); + if (!pDocSh) + return nullptr; const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>( pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST)); const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr; |