sfx2/source/view/viewfrm.cxx | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-)
New commits: commit 8067c5a66538b2fc31bbed9d5ae7dbfcaa6821f6 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Jul 19 14:53:52 2022 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Thu Aug 18 19:17:16 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 85a044abdf08bafa93e1caddf38f86e35d7e17f2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137184 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 7f3bf1a6bcc2..dfc0792ae9b2 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();