# HG changeset patch # User Chris Cannam # Date 1589470820 -3600 # Node ID 9910ba30a57281b3435d74617d4dd66abe02c906 # Parent 11a552b3ad8806847f07f32b35b8326349ff3e96 Update subrepos with various performance tweaks; when rebuilding menus, delete old actions (turns out addAction(QAction*) doesn't take ownership - I did know this once, but...) diff -r 11a552b3ad88 -r 9910ba30a572 main/MainWindow.cpp --- a/main/MainWindow.cpp Wed May 13 14:27:26 2020 +0100 +++ b/main/MainWindow.cpp Thu May 14 16:40:20 2020 +0100 @@ -346,7 +346,7 @@ config.testPath = "feedback41-present.txt"; config.surveyPath = "feedback41.php"; config.countdownKey = "countdown41"; - config.countdownFrom = 1; + config.countdownFrom = 5; config.title = "Sonic Visualiser - Can you help?"; config.text = "

Sonic Visualiser: Can you help?

" "

Are you using Sonic Visualiser in academic research or for commercial purposes? Or do you intend to do so?

" @@ -1221,22 +1221,19 @@ void MainWindow::setupPaneAndLayerMenus() { + Profiler profiler("MainWindow::setupPaneAndLayerMenus"); + if (m_paneMenu) { + m_paneMenu->clear(); + for (auto a: m_paneActions) { + delete a.first; + } m_paneActions.clear(); - m_paneMenu->clear(); } else { m_paneMenu = menuBar()->addMenu(tr("&Pane")); m_paneMenu->setTearOffEnabled(true); } - if (m_layerMenu) { - m_layerActions.clear(); - m_layerMenu->clear(); - } else { - m_layerMenu = menuBar()->addMenu(tr("&Layer")); - m_layerMenu->setTearOffEnabled(true); - } - if (m_rightButtonLayerMenu) { m_rightButtonLayerMenu->clear(); } else { @@ -1245,6 +1242,17 @@ m_rightButtonMenu->addSeparator(); } + if (m_layerMenu) { + m_layerMenu->clear(); + for (auto a: m_layerActions) { + delete a.first; + } + m_layerActions.clear(); + } else { + m_layerMenu = menuBar()->addMenu(tr("&Layer")); + m_layerMenu->setTearOffEnabled(true); + } + QMenu *menu = m_paneMenu; IconLoader il; @@ -1680,9 +1688,13 @@ MainWindow::setupTransformsMenu() { if (m_transformsMenu) { + m_transformsMenu->clear(); + m_recentTransformsMenu->clear(); + m_transformActionsReverse.clear(); m_transformActions.clear(); - m_transformActionsReverse.clear(); - m_transformsMenu->clear(); + for (auto a: m_transformActions) { + delete a.first; + } } else { m_transformsMenu = menuBar()->addMenu(tr("&Transform")); m_transformsMenu->setTearOffEnabled(true); @@ -1971,7 +1983,7 @@ vector files = m_recentFiles.getRecent(); for (size_t i = 0; i < files.size(); ++i) { QString path = files[i]; - QAction *action = new QAction(path, this); + QAction *action = m_recentFilesMenu->addAction(path); action->setObjectName(path); connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); if (i == 0) { @@ -1981,7 +1993,6 @@ action->shortcut().toString(), tr("Re-open the current or most recently opened file")); } - m_recentFilesMenu->addAction(action); } } @@ -1990,10 +2001,9 @@ { m_templatesMenu->clear(); - QAction *defaultAction = new QAction(tr("Standard Waveform"), this); + QAction *defaultAction = m_templatesMenu->addAction(tr("Standard Waveform")); defaultAction->setObjectName("default"); connect(defaultAction, SIGNAL(triggered()), this, SLOT(applyTemplate())); - m_templatesMenu->addAction(defaultAction); m_templatesMenu->addSeparator(); @@ -2012,9 +2022,8 @@ foreach (QString t, byName) { if (t.toLower() == "default") continue; - action = new QAction(t, this); + action = m_templatesMenu->addAction(t); connect(action, SIGNAL(triggered()), this, SLOT(applyTemplate())); - m_templatesMenu->addAction(action); } if (!templates.empty()) m_templatesMenu->addSeparator(); @@ -2026,11 +2035,11 @@ this, SLOT(setupTemplatesMenu())); } - QAction *setDefaultAction = new QAction(tr("Choose Default Template..."), this); + m_templatesMenu->addSeparator(); + + QAction *setDefaultAction = m_templatesMenu->addAction(tr("Choose Default Template...")); setDefaultAction->setObjectName("set_default_template"); connect(setDefaultAction, SIGNAL(triggered()), this, SLOT(preferences())); - m_templatesMenu->addSeparator(); - m_templatesMenu->addAction(setDefaultAction); m_manageTemplatesAction->setEnabled(havePersonal); } @@ -2070,10 +2079,18 @@ // SVDEBUG << "MainWindow::setupExistingLayersMenu" << endl; + Profiler profiler1("MainWindow::setupExistingLayersMenu"); + m_existingLayersMenu->clear(); + for (auto a: m_existingLayerActions) { + delete a.first; + } m_existingLayerActions.clear(); m_sliceMenu->clear(); + for (auto a: m_sliceActions) { + delete a.first; + } m_sliceActions.clear(); IconLoader il; @@ -2110,6 +2127,8 @@ } } + Profiler profiler3("MainWindow::setupExistingLayersMenu: after sorting"); + map observedNames; for (size_t i = 0; i < orderedLayers.size(); ++i) { @@ -4836,6 +4855,7 @@ void MainWindow::layerRemoved(Layer *layer) { + Profiler profiler("MainWindow::layerRemoved"); setupExistingLayersMenus(); MainWindowBase::layerRemoved(layer); } diff -r 11a552b3ad88 -r 9910ba30a572 repoint-lock.json --- a/repoint-lock.json Wed May 13 14:27:26 2020 +0100 +++ b/repoint-lock.json Thu May 14 16:40:20 2020 +0100 @@ -4,13 +4,13 @@ "pin": "8ffb8985ae8f" }, "svcore": { - "pin": "db489a1ece9b" + "pin": "14747f24ad04" }, "svgui": { - "pin": "6616e1899daa" + "pin": "bd1a7c84da8c" }, "svapp": { - "pin": "4c91c95e146a" + "pin": "cf4e0f3c2406" }, "checker": { "pin": "e839338d3869"