sfx2/source/view/viewfrm.cxx | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-)
New commits: commit 06229e4df02ddccb0408538271e0fbf683847355 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Jul 19 14:53:52 2022 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Jul 19 20:01:22 2022 +0200 tdf#148913 sw: fix crash with pending infobars on Windows Usage of VclPtr<SfxInfoBarWindow> wasn't thread-safe on Windows, resulting random crashing during loading big documents. Regression from commit d89786054715b44aa983d0752484216825c74ae2 "tdf#125909 tdf#141298 sw: show (Hidden) Track Changes infobar". Change-Id: Ic6a6ad43a8cf7ea650ef6d1c0aa5c76c48763ea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137230 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit a3745e55c9976cb5f7cfce341bc5dc2e7fc4fa6e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137183 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index f0f539ca675d..3e09372dd781 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1537,27 +1537,41 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } - VclPtr<SfxInfoBarWindow> pInfoBar = - AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage, + // Track Changes infobar: add a button to show/hide Track Changes functions + // Hyphenation infobar: add a button to get more information + // tdf#148913 limit VclPtr usage for these + bool bTrackChanges = aInfobarData.msId == "hiddentrackchanges"; + if ( bTrackChanges || aInfobarData.msId == "hyphenationmissing" ) + { + VclPtr<SfxInfoBarWindow> pInfoBar = + AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage, aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType, aInfobarData.mbShowCloseButton); - // Track Changes infobar: add a button to show/hide Track Changes functions - if ( pInfoBar && aInfobarData.msId == "hiddentrackchanges" ) - { - weld::Button& rTrackChangesButton = pInfoBar->addButton(); - rTrackChangesButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON)); - rTrackChangesButton.connect_clicked(LINK(this, + // tdf#148913 don't extend this condition to keep it thread-safe + if (pInfoBar) + { + weld::Button& rButton = pInfoBar->addButton(); + rButton.set_label(SfxResId(bTrackChanges + ? STR_TRACK_CHANGES_BUTTON + : STR_HYPHENATION_BUTTON)); + if (bTrackChanges) + { + rButton.connect_clicked(LINK(this, SfxViewFrame, HiddenTrackChangesHandler)); + } + else + { + rButton.connect_clicked(LINK(this, + SfxViewFrame, HyphenationMissingHandler)); + } + } } - - // Hyphenation infobar: add a button to get more information - if ( pInfoBar && aInfobarData.msId == "hyphenationmissing" ) + else { - weld::Button& rHyphenationButton = pInfoBar->addButton(); - rHyphenationButton.set_label(SfxResId(STR_HYPHENATION_BUTTON)); - rHyphenationButton.connect_clicked(LINK(this, - SfxViewFrame, HyphenationMissingHandler)); + AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage, + aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType, + aInfobarData.mbShowCloseButton); } aPendingInfobars.pop_back();