sfx2/source/view/lokhelper.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit dae8f420dd37ba425aec49bf322497e6a18a41af
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Jul 23 19:21:03 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Jul 24 17:39:17 2025 +0200

    two arg lcl_generateJSON always derefs ViewShell
    
    Change-Id: Ib5069150acb0dc030a6ac326029155cf6c84c0b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188287
    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 fc15e29c4478..08f5e37fb603 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -447,13 +447,12 @@ static OString lcl_sanitizeJSONAsValue(const OString 
&rStr)
     return aBuf.makeStringAndClear();
 }
 
-static OString lcl_generateJSON(const SfxViewShell* pView, const 
boost::property_tree::ptree& rTree)
+static OString lcl_generateJSON(const SfxViewShell& rView, const 
boost::property_tree::ptree& rTree)
 {
-    assert(pView != nullptr && "pView must be valid");
     boost::property_tree::ptree aMessageProps = rTree;
-    aMessageProps.put("viewId", SfxLokHelper::getView(pView));
-    aMessageProps.put("part", pView->getPart());
-    aMessageProps.put("mode", pView->getEditMode());
+    aMessageProps.put("viewId", SfxLokHelper::getView(rView));
+    aMessageProps.put("part", rView.getPart());
+    aMessageProps.put("mode", rView.getEditMode());
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aMessageProps, false /* pretty 
*/);
     return OString(o3tl::trim(aStream.str()));
@@ -495,7 +494,7 @@ void SfxLokHelper::notifyOtherView(const SfxViewShell* 
pThisView, SfxViewShell c
         return;
 
     const int viewId = SfxLokHelper::getView(pThisView);
-    pOtherView->libreOfficeKitViewCallbackWithViewId(nType, 
lcl_generateJSON(pThisView, rTree), viewId);
+    pOtherView->libreOfficeKitViewCallbackWithViewId(nType, 
lcl_generateJSON(*pThisView, rTree), viewId);
 }
 
 void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType, 
std::string_view rKey,
@@ -549,7 +548,7 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* 
pThisView, int nType,
             // Payload is only dependent on pThisView.
             if (aPayload.isEmpty())
             {
-                aPayload = lcl_generateJSON(pThisView, rTree);
+                aPayload = lcl_generateJSON(*pThisView, rTree);
                 viewId = SfxLokHelper::getView(*pThisView);
             }
 

Reply via email to