Skip to content

Commit efacaab

Browse files
committed
qtui: Account for Qt 6 sending close events at shutdown
1 parent a5a1071 commit efacaab

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/qtui/main_window.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,27 @@ MainWindow::MainWindow()
223223
}
224224

225225
MainWindow::~MainWindow()
226+
{
227+
// should have already been called in teardown(), but we'll
228+
// make sure so that audqt isn't left with a dangling pointer
229+
audqt::unregister_dock_host();
230+
231+
if (m_search_tool)
232+
aud_plugin_remove_watch(m_search_tool, plugin_watcher, this);
233+
}
234+
235+
// should be called before QApplication::quit() in
236+
// order to tear down the UI in an orderly fashion
237+
void MainWindow::teardown()
226238
{
227239
QSettings settings(m_config_name, "QtUi");
228240
settings.setValue("geometry", saveGeometry());
229241
settings.setValue("windowState", saveState());
230242

243+
// destroy plugin windows explicitly, otherwise Qt may send close
244+
// events to them during QApplication shutdown, causing plugins to
245+
// be disabled at next startup
231246
audqt::unregister_dock_host();
232-
233-
if (m_search_tool)
234-
aud_plugin_remove_watch(m_search_tool, plugin_watcher, this);
235247
}
236248

237249
void MainWindow::closeEvent(QCloseEvent * e)

src/qtui/main_window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class MainWindow : public QMainWindow, audqt::DockHost
4141
MainWindow();
4242
~MainWindow();
4343

44+
void teardown();
45+
4446
private:
4547
QString m_config_name;
4648
DialogWindows m_dialogs;

src/qtui/qtui.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class QtUI : public audqt::QtIfacePlugin
6969
}
7070
}
7171

72-
void quit() { audqt::quit(); }
72+
void quit()
73+
{
74+
window->teardown();
75+
audqt::quit();
76+
}
7377
};
7478

7579
EXPORT QtUI aud_plugin_instance;

0 commit comments

Comments
 (0)