From 3c67e22c3d0028df31e060ea28fb9f96b9f65cdf Mon Sep 17 00:00:00 2001 From: yg2f Date: Sat, 28 Mar 2015 18:34:28 +0100 Subject: add : bool Object.is_queued_for_deletion() `object.is_queued_for_deletion()` return true if the object was `object.queue_free()` or `SceneTree.queue_delete(object)`. --- core/object.cpp | 7 +++++++ core/object.h | 4 +++- scene/main/scene_main_loop.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/object.cpp b/core/object.cpp index 2b83f728d1..f71521a0ff 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1503,6 +1503,8 @@ void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("XL_MESSAGE","message"),&Object::XL_MESSAGE); ObjectTypeDB::bind_method(_MD("tr","message"),&Object::tr); + ObjectTypeDB::bind_method(_MD("is_queued_for_deletion"),&Object::is_queued_for_deletion); + ADD_SIGNAL( MethodInfo("script_changed")); BIND_VMETHOD( MethodInfo("_notification",PropertyInfo(Variant::INT,"what")) ); @@ -1566,6 +1568,10 @@ void Object::get_translatable_strings(List *p_strings) const { } +bool Object::is_queued_for_deletion() const { + return _is_queued_for_deletion; +} + #ifdef TOOLS_ENABLED void Object::set_edited(bool p_edited) { @@ -1587,6 +1593,7 @@ Object::Object() { _instance_ID=0; _instance_ID = ObjectDB::add_instance(this); _can_translate=true; + _is_queued_for_deletion=false; script_instance=NULL; #ifdef TOOLS_ENABLED diff --git a/core/object.h b/core/object.h index eb885f5d20..849bfc8510 100644 --- a/core/object.h +++ b/core/object.h @@ -397,7 +397,6 @@ friend void postinitialize_handler(Object*); protected: - virtual bool _use_builtin_script() const { return false; } virtual void _initialize_typev() { initialize_type(); } virtual bool _setv(const StringName& p_name,const Variant &p_property) { return false; }; @@ -589,6 +588,9 @@ public: StringName XL_MESSAGE(const StringName& p_message) const; //translate message (internationalization) StringName tr(const StringName& p_message) const; //translate message (alternative) + bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete(), and returned by + bool is_queued_for_deletion() const; + _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate=p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } Object(); diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index ed3e419359..8e2dc93288 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -850,6 +850,7 @@ void SceneTree::queue_delete(Object *p_object) { _THREAD_SAFE_METHOD_ ERR_FAIL_NULL(p_object); + p_object->_is_queued_for_deletion = true; delete_queue.push_back(p_object->get_instance_ID()); } -- cgit v1.2.3 From 9cca88eb9261587875cc944a23811c9f1e62f492 Mon Sep 17 00:00:00 2001 From: UsernameIsAReservedWord Date: Sat, 28 Mar 2015 18:42:01 +0100 Subject: Update object.h --- core/object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/object.h b/core/object.h index 849bfc8510..0bd3d09c21 100644 --- a/core/object.h +++ b/core/object.h @@ -588,7 +588,7 @@ public: StringName XL_MESSAGE(const StringName& p_message) const; //translate message (internationalization) StringName tr(const StringName& p_message) const; //translate message (alternative) - bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete(), and returned by + bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete() bool is_queued_for_deletion() const; _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate=p_enable; } -- cgit v1.2.3