https://github.com/libsdl-org/Maelstrom/commit/b9c86859f430dfcd0673363916eae19127d796eb
From b9c86859f430dfcd0673363916eae19127d796eb Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 10 Oct 2012 23:45:09 -0700
Subject: [PATCH] Buttons which close the dialog should do so before their
action (which may change the current panel)
---
screenlib/UIDialogButton.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/screenlib/UIDialogButton.cpp b/screenlib/UIDialogButton.cpp
index 65674af0..cc6b8688 100644
--- a/screenlib/UIDialogButton.cpp
+++ b/screenlib/UIDialogButton.cpp
@@ -57,6 +57,11 @@ UIDialogButton::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
void
UIDialogButton::OnClick()
{
+ // Hide before doing the action (which may change the current panel)
+ if (m_closeDialog) {
+ GetUI()->HidePanel(GetUI()->GetCurrentPanel());
+ }
+
UIElementButton::OnClick();
if (m_statusID) {
@@ -65,7 +70,4 @@ UIDialogButton::OnClick()
static_cast<UIDialog*>(panel)->SetDialogStatus(m_statusID);
}
}
- if (m_closeDialog) {
- GetUI()->HidePanel(GetUI()->GetCurrentPanel());
- }
}