浏览代码

Added nullcheck to Window.

Lasse Öörni 12 年之前
父节点
当前提交
b495b263e4
共有 2 个文件被更改,包括 3 次插入5 次删除
  1. 1 4
      Engine/UI/UIElement.cpp
  2. 2 1
      Engine/UI/Window.cpp

+ 1 - 4
Engine/UI/UIElement.cpp

@@ -1195,10 +1195,7 @@ float UIElement::GetDerivedOpacity() const
 bool UIElement::HasFocus() const
 {
     UI* ui = GetSubsystem<UI>();
-    if (!ui)
-        return false;
-    else
-        return ui->GetFocusElement() == this;
+    return ui ? ui->GetFocusElement() == this : false;
 }
 
 XMLFile* UIElement::GetDefaultStyle(bool recursiveUp) const

+ 2 - 1
Engine/UI/Window.cpp

@@ -217,7 +217,8 @@ void Window::SetResizeBorder(const IntRect& rect)
 void Window::SetModal(bool modal)
 {
     UI* ui = GetSubsystem<UI>();
-    if (ui->SetModalElement(this, modal))
+    // UI may be null at shutdown if for example a script was holding a reference to this window
+    if (ui && ui->SetModalElement(this, modal))
         modal_ = modal;
 }