ソースを参照

Simplify returning a new MessageBox to AngelScript. Fix crash due to multiple handling of MessageBox acknowledge when modal status is manually reset.

Lasse Öörni 9 年 前
コミット
9db4af58e5
2 ファイル変更5 行追加4 行削除
  1. 2 4
      Source/Urho3D/AngelScript/UIAPI.cpp
  2. 3 0
      Source/Urho3D/UI/MessageBox.cpp

+ 2 - 4
Source/Urho3D/AngelScript/UIAPI.cpp

@@ -495,16 +495,14 @@ static void RegisterMenu(asIScriptEngine* engine)
 
 static MessageBox* ConstructMessageBox(const String& messageString, const String& titleString, XMLFile* layoutFile, XMLFile* styleFile)
 {
-    SharedPtr<MessageBox> messageBox(new MessageBox(GetScriptContext(), messageString, titleString, layoutFile, styleFile));
-    messageBox->AddRef();
-    return messageBox.Get();
+    return new MessageBox(GetScriptContext(), messageString, titleString, layoutFile, styleFile);
 }
 
 static void RegisterMessageBox(asIScriptEngine* engine)
 {
     // Do not register default UIElement constructor due to possible ambiguity with the Messagebox parameter constructor
     RegisterUIElement<MessageBox>(engine, "MessageBox", false, false);
-    engine->RegisterObjectBehaviour("MessageBox", asBEHAVE_FACTORY, "MessageBox@ f(const String&in messageString = String(), const String&in titleString = String(), XMLFile@+ layoutFile = null, XMLFile@+ styleFile = null)", asFUNCTION(ConstructMessageBox), asCALL_CDECL);
+    engine->RegisterObjectBehaviour("MessageBox", asBEHAVE_FACTORY, "MessageBox@+ f(const String&in messageString = String(), const String&in titleString = String(), XMLFile@+ layoutFile = null, XMLFile@+ styleFile = null)", asFUNCTION(ConstructMessageBox), asCALL_CDECL);
     engine->RegisterObjectMethod("MessageBox", "void set_title(const String&in)", asMETHOD(MessageBox, SetTitle), asCALL_THISCALL);
     engine->RegisterObjectMethod("MessageBox", "const String& get_title() const", asMETHOD(MessageBox, GetTitle), asCALL_THISCALL);
     engine->RegisterObjectMethod("MessageBox", "void set_message(const String&in)", asMETHOD(MessageBox, SetMessage), asCALL_THISCALL);

+ 3 - 0
Source/Urho3D/UI/MessageBox.cpp

@@ -149,7 +149,10 @@ void MessageBox::RemoveWindow()
     {
         Window* window = dynamic_cast<Window*>(window_.Get());
         if (window)
+        {
+            UnsubscribeFromEvent(E_MODALCHANGED);
             window->SetModal(false);
+        }
         RemoveChild(window_);
         window_.Reset();
     }