From 9c36b0237767cc42bfc74d77935f229f139a6663 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 24 Jul 2014 12:07:34 +0300 Subject: Fix possible crash in "reset windows". --- src/gui/widgets/window.cpp | 5 +++++ src/gui/windows/setupwindow.cpp | 12 ++++++++++++ src/gui/windows/setupwindow.h | 2 ++ 3 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index caf7dae91..f2f7c1dd1 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -79,6 +79,8 @@ #include "gui/fonts/font.h" +#include "gui/windows/setupwindow.h" + #include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" @@ -219,6 +221,9 @@ Window::~Window() if (gui) gui->removeDragged(this); + if (setupWindow) + setupWindow->unregisterWindowForReset(this); + client->windowRemoved(this); saveWindowState(); diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 7239061ff..93556ab08 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -243,6 +243,18 @@ void SetupWindow::registerWindowForReset(Window *const window) mWindowsToReset.push_back(window); } +void SetupWindow::unregisterWindowForReset(Window *const window) +{ + FOR_EACH (std::list::const_iterator, it, mWindowsToReset) + { + if (*it == window) + { + mWindowsToReset.erase(it); + return; + } + } +} + void SetupWindow::doCancel() { setVisible(false); diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index e604bf0de..40e820fcf 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -62,6 +62,8 @@ class SetupWindow final : public Window, void registerWindowForReset(Window *const window); + void unregisterWindowForReset(Window *const window); + void clearWindowsForReset() { mWindowsToReset.clear(); } -- cgit v1.2.3-70-g09d2