forked from qt-creator/qt-creator
Debugger: Use queued connection for menu actions
Pass the parent calling object to the addAction() functions and use a queued connection. This prevents the following sequence of events: 1. The menu is dismissed when selecting a menu item. 2. The deletion gets queued via deleteLater(). 2. The onTriggered action gets invoked and opens a dialog box. 3. The dialog box triggers the events to be processed. 4. The menu is deleted when processing the events, while still in the event function to handle the dismissal. This only affected the watch menu since the others were leaked. Added cleanup handlers for the other debugger menus to avoid leaking them. Task-number: QTCREATORBUG-26989 Change-Id: Ifa2c52d7bea884c55d43fa545e3e2870301e4052 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -179,51 +179,52 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev)
|
||||
|
||||
auto menu = new QMenu;
|
||||
|
||||
addAction(menu, tr("Update Module List"),
|
||||
addAction(this, menu, tr("Update Module List"),
|
||||
enabled && canReload,
|
||||
[this] { engine->reloadModules(); });
|
||||
|
||||
addAction(menu, tr("Show Source Files for Module \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Show Source Files for Module \"%1\"").arg(moduleName),
|
||||
tr("Show Source Files for Module"),
|
||||
moduleNameValid && enabled && canReload,
|
||||
[this, modulePath] { engine->loadSymbols(modulePath); });
|
||||
|
||||
// FIXME: Dependencies only available on Windows, when "depends" is installed.
|
||||
addAction(menu, tr("Show Dependencies of \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Show Dependencies of \"%1\"").arg(moduleName),
|
||||
tr("Show Dependencies"),
|
||||
moduleNameValid && !moduleName.isEmpty() && HostOsInfo::isWindowsHost(),
|
||||
[modulePath] { QtcProcess::startDetached({{"depends"}, {modulePath}}); });
|
||||
|
||||
addAction(menu, tr("Load Symbols for All Modules"),
|
||||
addAction(this, menu, tr("Load Symbols for All Modules"),
|
||||
enabled && canLoadSymbols,
|
||||
[this] { engine->loadAllSymbols(); });
|
||||
|
||||
addAction(menu, tr("Examine All Modules"),
|
||||
addAction(this, menu, tr("Examine All Modules"),
|
||||
enabled && canLoadSymbols,
|
||||
[this] { engine->examineModules(); });
|
||||
|
||||
addAction(menu, tr("Load Symbols for Module \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Load Symbols for Module \"%1\"").arg(moduleName),
|
||||
tr("Load Symbols for Module"),
|
||||
moduleNameValid && canLoadSymbols,
|
||||
[this, modulePath] { engine->loadSymbols(modulePath); });
|
||||
|
||||
addAction(menu, tr("Edit File \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Edit File \"%1\"").arg(moduleName),
|
||||
tr("Edit File"),
|
||||
moduleNameValid,
|
||||
[this, modulePath] { engine->gotoLocation(FilePath::fromString(modulePath)); });
|
||||
|
||||
addAction(menu, tr("Show Symbols in File \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Show Symbols in File \"%1\"").arg(moduleName),
|
||||
tr("Show Symbols"),
|
||||
canShowSymbols && moduleNameValid,
|
||||
[this, modulePath] { engine->requestModuleSymbols(modulePath); });
|
||||
|
||||
addAction(menu, tr("Show Sections in File \"%1\"").arg(moduleName),
|
||||
addAction(this, menu, tr("Show Sections in File \"%1\"").arg(moduleName),
|
||||
tr("Show Sections"),
|
||||
canShowSymbols && moduleNameValid,
|
||||
[this, modulePath] { engine->requestModuleSections(modulePath); });
|
||||
|
||||
menu->addAction(debuggerSettings()->settingsDialog.action());
|
||||
|
||||
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user