commit 9eb6b26b48deb3ad40948ff68d87e6e8c3740931
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Sun Jan 4 21:48:13 2026 +0100

    Fixup 999fb37e: do not short-circuit updateMacros in the middle of an 
action.
    
    This can cause crashes, for example when updateCommand has been run
    and no new recordUndo happens in a complex operation. Many cases can
    happen, and we try to catch all of them by looking whether an undo
    group has been open.
    
    Note that this condition is also used in BufferView::busy().
---
 src/Buffer.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index c7d765018f..f12cb3957e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3987,8 +3987,13 @@ void Buffer::updateMacros() const
        if (d->macro_lock)
                return;
 
-       // early exit if the buffer has not changed since last time
-       if (d->gui_ && d->update_macros_id_ == d->id_)
+       /** Optimization: early exit if the 3 following conditions hold.
+        * 1/ gui is used (otherwise some crashes can happen),
+        * 2/ we are not in the middle of a complex operation (ex: repaint
+        *    happens in the midle of a Paste because of a dialog),
+        * 3/ the buffer has not changed since last time.
+        */
+       if (d->gui_ && !undo().activeUndoGroup() && d->update_macros_id_ == 
d->id_)
                return;
        d->update_macros_id_ = d->id_;
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to