sfx2/source/view/lokhelper.cxx |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 3e23cba56886bf52c24f979abf3f93d04b5b111d
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Jul 23 19:30:09 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Jul 24 21:46:50 2025 +0200

    all lcl_generateJSON variants unconditionally deref the ViewShell arg
    
    Change-Id: I861bd87177e45c45efa2be7920f41b807fd0299b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188295
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index be52c1dc8b39..67614b55bf97 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -458,20 +458,19 @@ static OString lcl_generateJSON(const SfxViewShell& 
rView, const boost::property
     return OString(o3tl::trim(aStream.str()));
 }
 
-static inline OString lcl_generateJSON(const SfxViewShell* pView, int nViewId, 
std::string_view rKey,
+static inline OString lcl_generateJSON(const SfxViewShell& rView, int nViewId, 
std::string_view rKey,
                                        const OString& rPayload)
 {
-    assert(pView != nullptr && "pView must be valid");
     return OString::Concat("{ \"viewId\": \"") + OString::number(nViewId)
-           + "\", \"part\": \"" + OString::number(pView->getPart()) + "\", 
\"mode\": \""
-           + OString::number(pView->getEditMode()) + "\", \"" + rKey + "\": \""
+           + "\", \"part\": \"" + OString::number(rView.getPart()) + "\", 
\"mode\": \""
+           + OString::number(rView.getEditMode()) + "\", \"" + rKey + "\": \""
            + lcl_sanitizeJSONAsValue(rPayload) + "\" }";
 }
 
-static inline OString lcl_generateJSON(const SfxViewShell* pView, 
std::string_view rKey,
+static inline OString lcl_generateJSON(const SfxViewShell& rView, 
std::string_view rKey,
                                        const OString& rPayload)
 {
-    return lcl_generateJSON(pView, SfxLokHelper::getView(pView), rKey, 
rPayload);
+    return lcl_generateJSON(rView, SfxLokHelper::getView(rView), rKey, 
rPayload);
 }
 
 void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell 
const* pOtherView,
@@ -481,7 +480,7 @@ void SfxLokHelper::notifyOtherView(const SfxViewShell* 
pThisView, SfxViewShell c
     if (DisableCallbacks::disabled())
         return;
 
-    const OString aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
+    const OString aPayload = lcl_generateJSON(*pThisView, rKey, rPayload);
     const int viewId = SfxLokHelper::getView(pThisView);
     pOtherView->libreOfficeKitViewCallbackWithViewId(nType, aPayload, viewId);
 }
@@ -516,7 +515,7 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* 
pThisView, int nType, st
             // Payload is only dependent on pThisView.
             if (aPayload.isEmpty())
             {
-                aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
+                aPayload = lcl_generateJSON(*pThisView, rKey, rPayload);
                 viewId = SfxLokHelper::getView(*pThisView);
             }
 
@@ -560,7 +559,7 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* 
pThisView, int nType,
 
 OString SfxLokHelper::makePayloadJSON(const SfxViewShell* pThisView, int 
nViewId, std::string_view rKey, const OString& rPayload)
 {
-    return lcl_generateJSON(pThisView, nViewId, rKey, rPayload);
+    return lcl_generateJSON(*pThisView, nViewId, rKey, rPayload);
 }
 
 namespace {

Reply via email to