Просмотр исходного кода

Use the Ref::Hold stack object to guarantee clean-up.

Jon Watte 10 лет назад
Родитель
Сommit
c229ca079d
1 измененных файлов с 1 добавлено и 3 удалено
  1. 1 3
      gameplay/src/Control.cpp

+ 1 - 3
gameplay/src/Control.cpp

@@ -1055,7 +1055,7 @@ void Control::notifyListeners(Control::Listener::EventType eventType)
     // This method runs untrusted code by notifying listeners of events.
     // If the user calls exit() or otherwise releases this control, we
     // need to keep it alive until the method returns.
-    addRef();
+    Ref::Hold ref(this);
 
     controlEvent(eventType);
 
@@ -1074,8 +1074,6 @@ void Control::notifyListeners(Control::Listener::EventType eventType)
     }
 
     fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Control, controlEvent), dynamic_cast<void*>(this), eventType);
-
-    release();
 }
 
 void Control::controlEvent(Control::Listener::EventType evt)