summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-08-27 10:14:18 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-02-28 11:43:15 +0100
commitff7411bb3d3ff2c74210c8f7c5d71a1315d08cad (patch)
treea17afb0594055d058566d68a4ee6128e2f0037d1 /src/gui
parentddd86b80a2090d40e61126d81c69fad6a0545a14 (diff)
downloadmana-ff7411bb3d3ff2c74210c8f7c5d71a1315d08cad.tar.gz
mana-ff7411bb3d3ff2c74210c8f7c5d71a1315d08cad.tar.bz2
mana-ff7411bb3d3ff2c74210c8f7c5d71a1315d08cad.tar.xz
mana-ff7411bb3d3ff2c74210c8f7c5d71a1315d08cad.zip
Fixed unresponsive UI when switching server/char with Away dialog open
The UI became unresponsive as a result of not actually deleting the OkDialog. The dialog is now managed by the AwayListener, which now schedules Away dialog for deletion when necessary, using a DeathListener to clear the reference to the dialog. The WindowContainer now uses an std::set instead of std::list to keep track of widgets scheduled for deletion, to avoid crashing when a widget is scheduled for deletion multiple times.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/windowcontainer.cpp9
-rw-r--r--src/gui/widgets/windowcontainer.h6
2 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 36f0998f..4e350a9e 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -24,16 +24,15 @@
#include "gui/gui.h"
#include "gui/widgets/window.h"
-#include "utils/dtor.h"
-
#include <guichan/focushandler.hpp>
WindowContainer *windowContainer = nullptr;
void WindowContainer::logic()
{
- delete_all(mDeathList);
- mDeathList.clear();
+ for (auto widget : mScheduledDeletions)
+ delete widget;
+ mScheduledDeletions.clear();
gcn::Container::logic();
}
@@ -48,7 +47,7 @@ void WindowContainer::draw(gcn::Graphics *graphics)
void WindowContainer::scheduleDelete(gcn::Widget *widget)
{
- mDeathList.push_back(widget);
+ mScheduledDeletions.insert(widget);
}
void WindowContainer::adjustAfterResize(int oldScreenWidth,
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
index 6324b059..ff03a903 100644
--- a/src/gui/widgets/windowcontainer.h
+++ b/src/gui/widgets/windowcontainer.h
@@ -23,6 +23,8 @@
#include "gui/widgets/container.h"
+#include <set>
+
/**
* A window container. This container adds functionality for more convenient
* widget (windows in particular) destruction.
@@ -64,9 +66,9 @@ class WindowContainer : public Container
bool widgetIsVisible(gcn::Widget *widget);
/**
- * List of widgets that are scheduled to be deleted.
+ * Set of widgets that are scheduled to be deleted.
*/
- std::list<gcn::Widget *> mDeathList;
+ std::set<gcn::Widget *> mScheduledDeletions;
};
extern WindowContainer *windowContainer;