[Libreoffice-commits] core.git: framework/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 16 15:14:09 UTC 2021


 framework/source/fwe/helper/undomanagerhelper.cxx |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 4ecb94da9fdd00f24b02020151ac4d27d5514d5f
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Jul 20 16:12:26 2021 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Mon Aug 16 17:09:21 2021 +0200

    Resolves: tdf#142980 Special-case the very first listener added during action
    
    Change-Id: I8bc3475581d9525db8e83bc1551326c474e752bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119275
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index a621a39ae320..33d1fade47c7 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -210,6 +210,7 @@ namespace framework
         IUndoManagerImplementation&         m_rUndoManagerImplementation;
         ::std::stack< bool >                m_aContextVisibilities;
 #if OSL_DEBUG_LEVEL > 0
+        bool                                m_bContextAPIFlagsEverPushed = {false};
         ::std::stack< bool >                m_aContextAPIFlags;
 #endif
         ::std::queue< ::rtl::Reference< UndoManagerRequest > >
@@ -797,6 +798,7 @@ namespace framework
     {
 #if OSL_DEBUG_LEVEL > 0
         m_aContextAPIFlags.push( m_bAPIActionRunning );
+        m_bContextAPIFlagsEverPushed = true;
 #endif
 
         if ( m_bAPIActionRunning )
@@ -808,9 +810,18 @@ namespace framework
     void UndoManagerHelper_Impl::listActionLeft( const OUString& i_comment )
     {
 #if OSL_DEBUG_LEVEL > 0
-        const bool bCurrentContextIsAPIContext = m_aContextAPIFlags.top();
-        m_aContextAPIFlags.pop();
-        OSL_ENSURE( bCurrentContextIsAPIContext == m_bAPIActionRunning, "UndoManagerHelper_Impl::listActionLeft: API and non-API contexts interwoven!" );
+        // It may happen that the very first event listener is added during a
+        // list action after listActionEntered() was already called, e.g. Calc
+        // formula calculation event listener during the input of the very
+        // first formula. Instead of checking m_aContextAPIFlags for empty,
+        // still assert (on calling top()) other stack mismatches but ignore
+        // this one case. See tdf#142980
+        if (m_bContextAPIFlagsEverPushed)
+        {
+            const bool bCurrentContextIsAPIContext = m_aContextAPIFlags.top();
+            m_aContextAPIFlags.pop();
+            OSL_ENSURE( bCurrentContextIsAPIContext == m_bAPIActionRunning, "UndoManagerHelper_Impl::listActionLeft: API and non-API contexts interwoven!" );
+        }
 #endif
 
         if ( m_bAPIActionRunning )


More information about the Libreoffice-commits mailing list