sfx2/source/control/unoctitm.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
New commits: commit 776f73c28f7a4984c8a932a5316a0cc0837e71e3 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Apr 12 08:52:43 2024 +0200 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Sat Apr 13 12:30:45 2024 +0200 sfx2: fix crash in InterceptLOKStateChangeEvent() Notice how e.g. the TransformPosX case already performed the same null pointer check. Crashreport backtrace: > program/libmergedlo.so > InterceptLOKStateChangeEvent > sfx2/source/control/unoctitm.cxx:1143 > program/libmergedlo.so > SfxStateCache::SetState_Impl(SfxItemState, SfxPoolItem const*, bool) > sfx2/source/control/statcach.cxx:432 > program/libmergedlo.so > SfxBindings::Update_Impl(SfxStateCache&) > /opt/rh/devtoolset-10/root/usr/include/c++/10/bits/stl_vector.h:919 (discriminator 2) > program/libmergedlo.so > SfxBindings::NextJob_Impl(Timer const*) > /opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:173 Change-Id: I141d4f9ec50d0ce7a0eeaba69752c31390a1f9ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166027 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165942 Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index d99446d01d79..b62f0f4376c4 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1118,13 +1118,17 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra else if (aEvent.FeatureURL.Path == "ParaLeftToRight" || aEvent.FeatureURL.Path == "ParaRightToLeft") { - tools::JsonWriter aTree; - bool bTemp = false; - aEvent.State >>= bTemp; - aTree.put("commandName", aEvent.FeatureURL.Complete); - aTree.put("disabled", !aEvent.IsEnabled); - aTree.put("state", bTemp ? "true" : "false"); - SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aTree.finishAndGetAsOString()); + const SfxViewShell* pViewShell = SfxViewShell::Current(); + if (pViewShell) + { + tools::JsonWriter aTree; + bool bTemp = false; + aEvent.State >>= bTemp; + aTree.put("commandName", aEvent.FeatureURL.Complete); + aTree.put("disabled", !aEvent.IsEnabled); + aTree.put("state", bTemp ? "true" : "false"); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aTree.finishAndGetAsOString()); + } return; } else if (aEvent.FeatureURL.Path == "AssignLayout" ||