From 516b60826d2d4ac455095ae18170ca68cc2d5f4c Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 12 Mar 2022 13:38:46 +0800 Subject: [PATCH] Gui: fix macro command sync in Customize -> Keyboard/Toolbar --- src/Gui/DlgKeyboardImp.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Gui/DlgKeyboardImp.cpp b/src/Gui/DlgKeyboardImp.cpp index e95aa6b8b5..89aef4b8a0 100644 --- a/src/Gui/DlgKeyboardImp.cpp +++ b/src/Gui/DlgKeyboardImp.cpp @@ -177,11 +177,18 @@ DlgCustomKeyboardImp::initCommandList(QTreeWidget *commandTreeWidget, QComboBox populateCommandGroups(combo); - return Application::Instance->commandManager().signalChanged.connect([combo](){ - if (combo) { - populateCommandGroups(combo); - combo->activated(combo->currentIndex()); - } + // Using a timer to respond for command change for performance, and also + // because macro command may be added before proper initialization (null + // menu text, etc.) + QTimer *timer = new QTimer(combo); + timer->setSingleShot(true); + QObject::connect(timer, &QTimer::timeout, [combo](){ + populateCommandGroups(combo); + combo->activated(combo->currentIndex()); + }); + + return Application::Instance->commandManager().signalChanged.connect([timer](){ + timer->start(100); }); }