diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-10-31 20:46:56 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-10-31 19:13:47 +0100 |
commit | 9a07b6c34c12d998b0428a5f70a4833bade3ef1f (patch) | |
tree | 3ca9eaf48d1e90ab485b5473347e3db7366ddf24 | |
parent | 15eb26d0f22c621f81086fc8d3c6525838adb426 (diff) |
tdf#163697: avoid premature handling of following notifications
This avoids re-entry to Document::handleParagraphNotifications, which
already was known to be problematic (see comments in Document::Notify,
and m_bSelectionChangedNotification introduced to avoid one such case).
Change-Id: I9e0b451f13ad109d08b1afc9cc0346cd6049b026
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175879
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | accessibility/inc/extended/textwindowaccessibility.hxx | 1 | ||||
-rw-r--r-- | accessibility/source/extended/textwindowaccessibility.cxx | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/accessibility/inc/extended/textwindowaccessibility.hxx b/accessibility/inc/extended/textwindowaccessibility.hxx index 44652bc87d3c..e998ac3c443e 100644 --- a/accessibility/inc/extended/textwindowaccessibility.hxx +++ b/accessibility/inc/extended/textwindowaccessibility.hxx @@ -572,6 +572,7 @@ private: std::queue< ::TextHint > m_aParagraphNotifications; bool m_bSelectionChangedNotification; + bool m_bInParagraphNotificationsHandler = false; }; } diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index ac8c0a736ab1..8692e5fcd0ff 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -1670,6 +1670,16 @@ Document::changeParagraphText(::sal_uInt32 nNumber, ::sal_uInt16 nBegin, ::sal_u void Document::handleParagraphNotifications() { + // Recursion is possible, e.g. when SfxHintId::TextParaInserted is being handled, + // and TextEngine::GetTextHeight is called for the paragraph being inserted; that + // tries to handle the following SfxHintId::TextFormatPara notification at the + // moment when the respective element hasn't yet been inserted into m_aParagraphs, + // which could crash. Therefore, re-entry is not allowed. The handling is done in + // a loop anyway, so it will process all of them in due order. + // See also comments in Document::Notify. + if (m_bInParagraphNotificationsHandler) + return; + m_bInParagraphNotificationsHandler = true; while (!m_aParagraphNotifications.empty()) { ::TextHint aHint(m_aParagraphNotifications.front()); @@ -1856,6 +1866,7 @@ void Document::handleParagraphNotifications() break; } } + m_bInParagraphNotificationsHandler = false; if (m_bSelectionChangedNotification) { m_bSelectionChangedNotification = false; |