Maelstrom: Unanchor areas when they are deleted

https://github.com/libsdl-org/Maelstrom/commit/0c3f55219be6c7ac0581b7d129e37d523e4b2ef7

From 0c3f55219be6c7ac0581b7d129e37d523e4b2ef7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 13 Sep 2012 23:18:11 -0700
Subject: [PATCH] Unanchor areas when they are deleted

---
 screenlib/UIArea.cpp | 7 +++++++
 screenlib/UIArea.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/screenlib/UIArea.cpp b/screenlib/UIArea.cpp
index 2f36d955..59cff532 100644
--- a/screenlib/UIArea.cpp
+++ b/screenlib/UIArea.cpp
@@ -41,6 +41,13 @@ UIArea::UIArea(UIArea *anchor, int w, int h) : ErrorBase()
 	}
 }
 
+UIArea::~UIArea()
+{
+	if (m_anchor.element) {
+		m_anchor.element->DelAnchoredArea(this);
+	}
+}
+
 bool
 UIArea::Load(rapidxml::xml_node<> *node)
 {
diff --git a/screenlib/UIArea.h b/screenlib/UIArea.h
index 6505a1aa..9040fde3 100644
--- a/screenlib/UIArea.h
+++ b/screenlib/UIArea.h
@@ -54,6 +54,7 @@ class UIArea : public ErrorBase
 {
 public:
 	UIArea(UIArea *anchor = NULL, int w = 0, int h = 0);
+	virtual ~UIArea();
 
 	bool Load(rapidxml::xml_node<> *node);