From 3484abd4af85a159abcf62b1d469d61341b3812e Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 8 Apr 2018 14:13:48 +0200 Subject: [PATCH] fixed popups not getting deleted on close --- src/singletons/windowmanager.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/singletons/windowmanager.cpp b/src/singletons/windowmanager.cpp index 8f8ce007b..1530062bc 100644 --- a/src/singletons/windowmanager.cpp +++ b/src/singletons/windowmanager.cpp @@ -95,10 +95,22 @@ widgets::Window &WindowManager::getSelectedWindow() widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type) { auto *window = new widgets::Window(this->themeManager, type); - this->windows.push_back(window); window->show(); + if (type != widgets::Window::Main) { + window->setAttribute(Qt::WA_DeleteOnClose); + + QObject::connect(window, &QWidget::destroyed, [this, window] { + for (auto it = this->windows.begin(); it != this->windows.end(); it++) { + if (*it == window) { + this->windows.erase(it); + break; + } + } + }); + } + return *window; }