summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-02-12 03:40:01 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-12 19:17:06 +0300
commit0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0 (patch)
treee726c4c04bef0639aaee1bc4d903f94e7ce728c1 /src/gui/widgets
parent0e1d656e85e1bbc80e9e8adcfb2c07a8bc0d4bb8 (diff)
downloadmanaverse-0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0.tar.gz
manaverse-0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0.tar.bz2
manaverse-0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0.tar.xz
manaverse-0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0.zip
Dont allow add same window into delete list more than once.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/windowcontainer.cpp18
-rw-r--r--src/gui/widgets/windowcontainer.h3
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;