From 85f3f8de19e63f41e9c304427e9f7a840480f21c Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Wed, 11 Dec 2019 14:54:56 +0100 Subject: Avoid crash when no uno name available Change-Id: I81895e68d6fda46bec0cc3bca2da63901d3fed4c Reviewed-on: https://gerrit.libreoffice.org/84949 Reviewed-by: Aron Budea Tested-by: Aron Budea --- sfx2/source/view/lokhelper.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 5802a9b96ad8..2232b397996d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -220,14 +220,18 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS namespace { OUString lcl_getNameForSlot(const SfxViewShell* pShell, sal_uInt16 nWhich) { - if (pShell->GetFrame()) + if (pShell && pShell->GetFrame()) { const SfxSlot* pSlot = SfxSlotPool::GetSlotPool(pShell->GetFrame()).GetSlot(nWhich); if (pSlot) { OUStringBuffer sUnoCommand(".uno:"); - sUnoCommand.append(OStringToOUString(pSlot->GetUnoName(), RTL_TEXTENCODING_ASCII_US)); - return sUnoCommand.makeStringAndClear(); + const char* pName = pSlot->GetUnoName(); + if (pName) + { + sUnoCommand.append(OStringToOUString(pName, RTL_TEXTENCODING_ASCII_US)); + return sUnoCommand.makeStringAndClear(); + } } } @@ -237,7 +241,7 @@ namespace { void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem) { - if (!pShell || !pItem || DisableCallbacks::disabled()) + if (!pShell || !pItem || pItem == reinterpret_cast(-1) || DisableCallbacks::disabled()) return; boost::property_tree::ptree aItem = pItem->dumpAsJSON(); -- cgit v1.2.3