fixed popups not getting deleted on close

This commit is contained in:
fourtf 2018-04-08 14:13:48 +02:00
parent 1ed426178a
commit 992f0ab06a

View file

@ -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;
}