diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/windowcontainer.cpp | 18 | ||||
-rw-r--r-- | src/gui/widgets/windowcontainer.h | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index a0e4e8dad..a275b7cb1 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -24,6 +24,7 @@ #include "gui/widgets/window.h" +#include "utils/checkutils.h" #include "utils/dtor.h" #include "utils/foreach.h" @@ -33,7 +34,8 @@ WindowContainer *windowContainer = nullptr; WindowContainer::WindowContainer(const Widget2 *const widget) : Container(widget), - mDeathList() + mDeathList(), + mDeathSet() { } @@ -41,12 +43,24 @@ void WindowContainer::slowLogic() { delete_all(mDeathList); mDeathList.clear(); + mDeathSet.clear(); } void WindowContainer::scheduleDelete(Widget *const widget) { - if (widget != nullptr) + if (widget == nullptr) + return; + + if (mDeathSet.find(widget) == mDeathSet.end()) + { mDeathList.push_back(widget); + mDeathSet.insert(widget); + } + else + { + reportAlways("double adding pointer %p for deletion in scheduleDelete", + static_cast<void*>(widget)); + } } void WindowContainer::adjustAfterResize(const int oldScreenWidth, diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 10c96e88d..0c04849e6 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -25,6 +25,8 @@ #include "gui/widgets/container.h" +#include <set> + /** * A window container. This container adds functionality for more convenient * widget (windows in particular) destruction. @@ -67,6 +69,7 @@ class WindowContainer notfinal : public Container typedef STD_VECTOR<Widget*> Widgets; typedef Widgets::iterator WidgetIterator; Widgets mDeathList; + std::set<Widget*> mDeathSet; }; extern WindowContainer *windowContainer; |