sw/source/uibase/docvw/AnnotationWin.cxx  |    9 ++++++---
 sw/source/uibase/docvw/AnnotationWin2.cxx |   10 ++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 946ca1b3f7617e9c6bb81d58096b03c50318b88f
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu May 30 08:47:09 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri May 31 09:28:14 2024 +0200

    ubsan: runtime error: reference binding to null pointer of type 'const 
SwFrame'
    
    since:
    
    commit 124a988ea99096ea5080060c0d1a801528bd7a5c
    Date:   Wed May 22 11:57:57 2024 +0100
    
        create comment reply synchronously
    
    Change-Id: I62a6499c4dda7155e95bf8ffb344bfa81750844f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168200
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index 714c1419d2ed..426c097e9e58 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -120,9 +120,12 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
     }
 
 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
-    mrMgr.ConnectSidebarWinToFrame( 
*(mrSidebarItem.maLayoutInfo.mpAnchorFrame),
-                                  mrSidebarItem.GetFormatField(),
-                                  *this );
+    if (rSidebarItem.maLayoutInfo.mpAnchorFrame)
+    {
+        mrMgr.ConnectSidebarWinToFrame( 
*(rSidebarItem.maLayoutInfo.mpAnchorFrame),
+                                      mrSidebarItem.GetFormatField(),
+                                      *this );
+    }
 #endif
 
     if (SupportsDoubleBuffering())
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index a1f6e5794f1a..73c035abdaf7 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1063,16 +1063,13 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
 
             SwDocShell* pShell = mrView.GetDocShell();
             if (bReply)
-                
pShell->GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::START, nullptr);
+                
pShell->GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
 
             // synchronous dispatch
             mrView.GetViewFrame().GetDispatcher()->Execute(FN_POSTIT);
 
             if (bReply)
             {
-                SwUndoId nUndoId(SwUndoId::END);
-                mrView.GetWrtShell().GetLastUndoInfo(nullptr, &nUndoId);
-
                 // Get newly created SwPostItField and set its paraIdParent
                 auto pPostItField = mrMgr.GetLatestPostItField();
                 pPostItField->SetParentId(GetTopReplyNote()->GetParaId());
@@ -1088,7 +1085,7 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
 
                 SwRewriter aRewriter;
                 aRewriter.AddRule(UndoArg1, pPostItField->GetDescription());
-                pShell->GetDoc()->GetIDocumentUndoRedo().EndUndo(nUndoId, 
&aRewriter);
+                
pShell->GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
             }
             break;
         }
@@ -1416,7 +1413,7 @@ void SwAnnotationWin::ChangeSidebarItem( SwSidebarItem 
const & rSidebarItem )
 {
 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
     const bool bAnchorChanged = mpAnchorFrame != 
rSidebarItem.maLayoutInfo.mpAnchorFrame;
-    if ( bAnchorChanged )
+    if (bAnchorChanged && mpAnchorFrame)
     {
         mrMgr.DisconnectSidebarWinFromFrame( *mpAnchorFrame, *this );
     }
@@ -1424,6 +1421,7 @@ void SwAnnotationWin::ChangeSidebarItem( SwSidebarItem 
const & rSidebarItem )
 
     mrSidebarItem = rSidebarItem;
     mpAnchorFrame = mrSidebarItem.maLayoutInfo.mpAnchorFrame;
+    assert(mpAnchorFrame);
 
 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
     if (mxSidebarWinAccessible)

Reply via email to