https://github.com/libsdl-org/Maelstrom/commit/d3c2e901cde0411865ba3e3a65a599ff709aed84
From d3c2e901cde0411865ba3e3a65a599ff709aed84 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 13 Oct 2012 17:21:07 -0700
Subject: [PATCH] Make sure all of the dialog actions are done before
dispatching the button action
---
screenlib/UIDialogButton.cpp | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/screenlib/UIDialogButton.cpp b/screenlib/UIDialogButton.cpp
index cc6b8688..44622006 100644
--- a/screenlib/UIDialogButton.cpp
+++ b/screenlib/UIDialogButton.cpp
@@ -57,17 +57,16 @@ UIDialogButton::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
void
UIDialogButton::OnClick()
{
+ UIPanel *panel = GetUI()->GetCurrentPanel();
+
// Hide before doing the action (which may change the current panel)
- if (m_closeDialog) {
- GetUI()->HidePanel(GetUI()->GetCurrentPanel());
+ if (m_closeDialog && panel) {
+ GetUI()->HidePanel(panel);
}
- UIElementButton::OnClick();
-
- if (m_statusID) {
- UIPanel *panel = GetUI()->GetCurrentPanel();
- if (panel && panel->IsA(UIDialog::GetType())) {
- static_cast<UIDialog*>(panel)->SetDialogStatus(m_statusID);
- }
+ if (m_statusID && panel && panel->IsA(UIDialog::GetType())) {
+ static_cast<UIDialog*>(panel)->SetDialogStatus(m_statusID);
}
+
+ UIElementButton::OnClick();
}