Skip to content

Commit

Permalink
Defer broadcast of postit field update from layout
Browse files Browse the repository at this point in the history
until oTextPara has been applied to the field's associated postit
window.

This became a noticeable problem since:

commit 2fba6df
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.

2fba6df 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 <[email protected]>
Reviewed-by: Pranam Lashkari <[email protected]>
(cherry picked from commit c29a10b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178390
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <[email protected]>
  • Loading branch information
caolanm committed Dec 13, 2024
1 parent 0b9573b commit f1ec7d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sw/source/uibase/wrtsh/wrtsh1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2346,18 +2346,24 @@ 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();
SwCursorShell::Left(1, SwCursorSkipMode::Chars);
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
Expand Down

0 comments on commit f1ec7d9

Please sign in to comment.