1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

-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
This commit is contained in:
Juan Linietsky
2014-04-05 12:39:30 -03:00
parent 35b84d2c85
commit 9f33134c93
47 changed files with 1599 additions and 268 deletions

View File

@@ -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
}