sw/source/uibase/wrtsh/wrtsh1.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit c29a10b51db8027f90397d1bd9e31bd8a3571bc6
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Dec 11 16:24:00 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Dec 11 20:24:43 2024 +0100

    Defer broadcast of postit field update from layout
    
    until oTextPara has been applied to the field's associated postit
    window.
    
    This became a noticeable problem since:
    
    commit 2fba6df7242586870988b62909156538b42c2bc0
    CommitDate: Thu Dec 5 15:31:06 2024 +0100
    
        LOK: don't recreate the dialogs of an old view when loading new views
    
    In the broken situation the contents of the postit are sent back to kit
    as apparently empty, so newly inserted comments appear to be empty.
    
    The broadcast bt of this scenario is:
    
     #0  sw::annotation::SwAnnotationWin::GetSimpleHtml (this=0x19f38790) at 
sw/source/uibase/docvw/AnnotationWin.cxx:516
     #1  0x00007f37d246283e in (anonymous namespace)::lcl_CommentNotification 
(pView=0x267cac40, nType=(anonymous namespace)::CommentNotificationType::Add,
         pItem=0x26baf4e0, nPostItId=0) at 
sw/source/uibase/docvw/PostItMgr.cxx:176
     #2  0x00007f37d2467fef in SwPostItMgr::LayoutPostIts (this=0x266d7160) at 
sw/source/uibase/docvw/PostItMgr.cxx:1084
     #3  0x00007f37d209dd1b in SwViewShell::VisPortChgd (this=0x267cce90, 
rRect=...) at sw/source/core/view/viewsh.cxx:1326
     #4  0x00007f37d119030d in SwCursorShell::VisPortChgd (this=0x267cce90, 
rRect=...) at sw/source/core/crsr/crsrsh.cxx:1788
     #5  0x00007f37d276478b in SwView::SetVisArea (this=0x267cac40, rRect=..., 
bUpdateScrollbar=true)
         at sw/source/uibase/uiview/viewport.cxx:249
     #6  0x00007f37d2764cc3 in SwView::SetVisArea (this=0x267cac40, rPt=..., 
bUpdateScrollbar=true)
         at sw/source/uibase/uiview/viewport.cxx:311
     #7  0x00007f37d2765e2e in SwView::Scroll (this=0x267cac40, rRect=..., 
nRangeX=65535, nRangeY=65535)
         at sw/source/uibase/uiview/viewport.cxx:495
     #8  0x00007f37d24d7708 in ScrollMDI (pVwSh=0x267cce90, rRect=..., 
nRangeX=65535, nRangeY=65535)
         at sw/source/uibase/docvw/edtwin3.cxx:41
     #9  0x00007f37d209a896 in SwViewShell::MakeVisible (this=0x267cce90, 
rRect=...) at sw/source/core/view/viewsh.cxx:665
     #10 0x00007f37d119a238 in SwCursorShell::MakeSelVisible (this=0x267cce90) 
at sw/source/core/crsr/crsrsh.cxx:3490
     #11 0x00007f37d1837671 in SwFEShell::MakeSelVisible (this=0x267cce90) at 
sw/source/core/frmedt/feshview.cxx:2677
     #12 0x00007f37d1192fcc in SwCursorShell::UpdateCursor (this=0x267cce90, 
eFlags=6, bIdleEnd=false)
         at sw/source/core/crsr/crsrsh.cxx:2345
     #13 0x00007f37d11886f9 in SwCursorShell::EndAction (this=0x267cce90, 
bIdleEnd=false) at sw/source/core/crsr/crsrsh.cxx:280
     #14 0x00007f37d178ed62 in SwEditShell::EndAllAction (this=0x267cce90) at 
sw/source/core/edit/edws.cxx:102
     #15 0x00007f37d2503daf in SwFieldMgr::InsertField (this=0x7fff88937c00, 
rData=...) at sw/source/uibase/fldui/fldmgr.cxx:1561
     #16 0x00007f37d292df75 in SwWrtShell::InsertPostIt (this=0x267cce90, 
rFieldMgr=..., rReq=...)
    
    while in the "working" case IsScrollMDI is false and MakeVisible returns 
early.
    
    2fba6df7 causes the profile's desire to restore core's SID_SIDEBAR to be
    ignored and so the results of IsScrollMDI differ between the two
    scenarios.
    
    Which makes it more likely that IsScrollMDI is true when queried by
    SwViewShell::MakeVisible, and so LayoutPostIts triggers before
    pPostIt->SetTextObject, so the contents of that TextObject, while
    applied to the postit, are not broadcast back via the kit.
    
    put a StartAction/EndAction pairing when oTextPara is present to
    suppress the update until oTextPara is applied.
    
    Change-Id: Id42ff1be85fec4b1053e5a7726cf6d2ba8d7de84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178326
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>

diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 94a27578fd68..7b1d9236c099 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2336,6 +2336,11 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, 
const SfxRequest& rReq)
             }
         }
 
+        // Defer broadcast of postit field update from layout until oTextPara 
has been
+        // applied to the field's associated postit window
+        if (oTextPara)
+            StartAction();
+
         rFieldMgr.InsertField( aData );
 
         Push();
@@ -2343,11 +2348,12 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, 
const SfxRequest& rReq)
         pPostIt = static_cast<SwPostItField*>(rFieldMgr.GetCurField());
 
         if (pPostIt && oTextPara)
-        {
             pPostIt->SetTextObject(*oTextPara);
-        }
 
         Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position
+
+        if (oTextPara)
+            EndAction();
     }
 
     // Client has disabled annotations rendering, no need to

Reply via email to