From 78e4a0aa136e78bdb71c81f5931792b9c16d12e7 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 5 Apr 2020 10:49:10 +0300 Subject: MainWindow: disconnect signals during closeEvent --- src/mainwindow/mainwindow.cpp | 7 +++++++ src/mainwindow/mainwindow.h | 1 + 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index e16f34f..c54c8e3 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -177,10 +177,14 @@ void MainWindow::setCurrentSubWindow(SubWindow *subwindow) setWindowTitle(QString("[%1] - %2").arg(subwindow->windowTitle(), defaultWindowTitle)); // connect signlas + disconnect(windowTitleConnection); disconnect(viewChangedConnection); disconnect(statusBarConnection); setView(subwindow->currentView()); + windowTitleConnection = connect(subwindow, &SubWindow::windowTitleChanged, this, [this](const QString &title) { + setWindowTitle(QString("[%1] - %2").arg(title, defaultWindowTitle)); + }); viewChangedConnection = connect(subwindow, &SubWindow::currentViewChanged, this, &MainWindow::setView); statusBarConnection = connect(subwindow, &SubWindow::showStatusMessage, statusBar(), &QStatusBar::showMessage); } @@ -201,5 +205,8 @@ void MainWindow::closeEvent(QCloseEvent *event) return; } } + disconnect(windowTitleConnection); + disconnect(viewChangedConnection); + disconnect(statusBarConnection); event->accept(); } diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index 2b9f82b..bec2cdd 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -86,6 +86,7 @@ private: QVector m_subwindows; + QMetaObject::Connection windowTitleConnection; QMetaObject::Connection viewChangedConnection; QMetaObject::Connection statusBarConnection; }; -- cgit v1.2.1