commit 1c7934b1b35e4cdb159b2ee97871010482239ee0
Author: Richard Kimberly Heck <[email protected]>
Date:   Mon Sep 7 15:02:28 2026 -0400

    Patch from Pavel addressing a memory leak
---
 configure.ac                    |  2 +-
 src/frontends/qt/GuiToolbar.cpp | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6eaa5d8e6d..05885008b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 dnl Process with autoconf to generate configure script   -*- sh -*-
 
-AC_INIT([LyX],[2.5.3],[[email protected]],[lyx])
+AC_INIT([LyX],[2.5.3+leakpatch],[[email protected]],[lyx])
 AC_PRESERVE_HELP_ORDER
 # Use ISO format only. The frontend needs to parse this
 AC_SUBST(LYX_DATE, ["2026-09-07"])
diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp
index 459984741c..e4e206dadf 100644
--- a/src/frontends/qt/GuiToolbar.cpp
+++ b/src/frontends/qt/GuiToolbar.cpp
@@ -421,6 +421,11 @@ void DynamicMenuButton::updateTriggered()
                           && !d->func_requests_.empty()
                           && 
lyx::getStatus(d->func_requests_.front()).enabled());
        } else if (menutype == "textstyle-apply") {
+               // LEAK-TEST: QMenu::clear() does NOT delete these actions, 
because
+               // they are parented to this button, not to the menu. Without 
this
+               // they accumulate on every toolbar update (i.e. every 
keystroke).
+               for (QAction * a : m->actions())
+                       delete a;
                m->clear();
                setPopupMode(QToolButton::MenuButtonPopup);
                if (!bv) {
@@ -461,6 +466,11 @@ void DynamicMenuButton::updateTriggered()
                
setEnabled(lyx::getStatus(FuncRequest(LFUN_TEXTSTYLE_APPLY)).enabled()
                           || 
lyx::getStatus(FuncRequest(LFUN_FONT_DEFAULT)).enabled());
        } else if (menutype == "paste") {
+               // LEAK-TEST: QMenu::clear() does NOT delete these actions, 
because
+               // they are parented to this button, not to the menu. Without 
this
+               // they accumulate on every toolbar update (i.e. every 
keystroke).
+               for (QAction * a : m->actions())
+                       delete a;
                m->clear();
                setPopupMode(QToolButton::MenuButtonPopup);
                Action * default_action = new Action(FuncRequest(LFUN_PASTE),
@@ -494,6 +504,11 @@ void DynamicMenuButton::updateTriggered()
 void DynamicMenuButton::loadFlexInsets()
 {
        QMenu * m = menu();
+       // LEAK-TEST: QMenu::clear() does NOT delete these actions, because
+       // they are parented to this button, not to the menu. Without this
+       // they accumulate on every toolbar update (i.e. every keystroke).
+       for (QAction * a : m->actions())
+               delete a;
        m->clear();
        d->func_requests_.clear();
        string const & menutype = tbitem_.name;
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to