summaryrefslogtreecommitdiffstats
path: root/ScreensPanel.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-12-08 14:44:48 +0100
committerChristian Göttsche <cgzones@googlemail.com>2021-12-08 16:34:15 +0100
commitc85e5bbf5c5697b47fb94903eb9d5c0f03f51ec7 (patch)
tree66dd6f2184d5b6de9d2f131614ea02319a4970e8 /ScreensPanel.c
parentc9e0bd20026faf5368b32f1880d6194a81c2aa92 (diff)
ScreenPanels: free ScreenSettings of deleted screens
Diffstat (limited to 'ScreensPanel.c')
-rw-r--r--ScreensPanel.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/ScreensPanel.c b/ScreensPanel.c
index 10370e4f..8d49127c 100644
--- a/ScreensPanel.c
+++ b/ScreensPanel.c
@@ -15,13 +15,22 @@ in the source distribution for its full text.
#include "FunctionBar.h"
#include "Hashtable.h"
#include "ProvideCurses.h"
+#include "Settings.h"
#include "XUtils.h"
+static void ScreenListItem_delete(Object* cast) {
+ ScreenListItem* this = (ScreenListItem*)cast;
+ if (this->ss) {
+ ScreenSettings_delete(this->ss);
+ }
+ ListItem_delete(cast);
+}
+
ObjectClass ScreenListItem_class = {
.extends = Class(ListItem),
.display = ListItem_display,
- .delete = ListItem_delete,
+ .delete = ScreenListItem_delete,
.compare = ListItem_compare
};
@@ -37,6 +46,14 @@ static const char* const ScreensFunctions[] = {" ", "Rename", " ", "
static void ScreensPanel_delete(Object* object) {
Panel* super = (Panel*) object;
ScreensPanel* this = (ScreensPanel*) object;
+
+ /* do not delete screen settings still in use */
+ int n = Panel_size(super);
+ for (int i = 0; i < n; i++) {
+ ScreenListItem* item = (ScreenListItem*) Panel_get(super, i);
+ item->ss = NULL;
+ }
+
Panel_done(super);
free(this);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy