diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-04-05 12:39:30 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-04-05 12:39:30 -0300 |
commit | 9f33134c93ecbadda70e8eefc50563e29b2eb7f2 (patch) | |
tree | 299ded94fe74a61bf8094935d0f3283f6f30e435 /core/object.cpp | |
parent | 35b84d2c85fd152bee05d7d5a05e20a5f602a285 (diff) | |
download | redot-engine-9f33134c93ecbadda70e8eefc50563e29b2eb7f2.tar.gz |
-Support for changing fonts
-Detect when free() might crash the project and throw error
-fixed 2D Bounce in physics (3d still broken)
-renamed “on_top” property to “behind_parent”, which makes more sense, old on_top remains there for compatibility but is invisible.
-large amount of fixes
Diffstat (limited to 'core/object.cpp')
-rw-r--r-- | core/object.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/core/object.cpp b/core/object.cpp index 692010b1b7..b40f4ec151 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -33,6 +33,30 @@ #include "message_queue.h" #include "core_string_names.h" #include "translation.h" + +#ifdef DEBUG_ENABLED + +struct _ObjectDebugLock { + + Object *obj; + + _ObjectDebugLock(Object *p_obj) { + obj=p_obj; + obj->_lock_index.ref(); + } + ~_ObjectDebugLock() { + obj->_lock_index.unref(); + } +}; + +#define OBJ_DEBUG_LOCK _ObjectDebugLock _debug_lock(this); + +#else + +#define OBJ_DEBUG_LOCK + +#endif + Array convert_property_list(const List<PropertyInfo> * p_list) { Array va; @@ -562,13 +586,22 @@ void Object::call_multilevel(const StringName& p_method,const Variant** p_args,i ERR_FAIL(); return; } + + + if (_lock_index.get()>1) { + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL(); + return; + } #endif + //must be here, must be before everything, memdelete(this); return; } //Variant ret; + OBJ_DEBUG_LOCK Variant::CallError error; @@ -594,6 +627,7 @@ void Object::call_multilevel_reversed(const StringName& p_method,const Variant** MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_method); Variant::CallError error; + OBJ_DEBUG_LOCK if (method) { @@ -813,6 +847,15 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL_V(Variant()); } + + if (_lock_index.get()>1) { + r_error.argument=0; + r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL_V(Variant()); + + } + #endif //must be here, must be before everything, memdelete(this); @@ -821,7 +864,7 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg } Variant ret; - + OBJ_DEBUG_LOCK if (script_instance) { ret = script_instance->call(p_method,p_args,p_argcount,r_error); //force jumptable @@ -902,7 +945,7 @@ void Object::set_script(const RefPtr& p_script) { Ref<Script> s(script); if (!s.is_null() && s->can_instance() ) { - + OBJ_DEBUG_LOCK script_instance = s->instance_create(this); } @@ -1066,6 +1109,8 @@ void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { int ssize = slot_map.size(); + OBJ_DEBUG_LOCK + for(int i=0;i<ssize;i++) { const Connection &c = slot_map.getv(i).conn; @@ -1536,6 +1581,11 @@ Object::Object() { _edited=false; #endif +#ifdef DEBUG_ENABLED + _lock_index.init(1); +#endif + + } |