diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 1b4ca8151b7a..e3360a23d20b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -246,6 +246,12 @@ Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); } +int _OS::get_process_ID() const { + + return OS::get_singleton()->get_process_ID(); +}; + + bool _OS::has_environment(const String& p_var) const { return OS::get_singleton()->has_environment(p_var); @@ -561,6 +567,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("execute","path","arguments","blocking"),&_OS::execute); ObjectTypeDB::bind_method(_MD("kill","pid"),&_OS::kill); ObjectTypeDB::bind_method(_MD("shell_open","uri"),&_OS::shell_open); + ObjectTypeDB::bind_method(_MD("get_process_ID"),&_OS::get_process_ID); ObjectTypeDB::bind_method(_MD("get_environment","environment"),&_OS::get_environment); ObjectTypeDB::bind_method(_MD("has_environment","environment"),&_OS::has_environment); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 3d03247c07d0..0084726547de 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -117,6 +117,8 @@ class _OS : public Object { Error kill(int p_pid); Error shell_open(String p_uri); + int get_process_ID() const; + bool has_environment(const String& p_var) const; String get_environment(const String& p_var) const; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 47f278596bda..33f4cafeddf2 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -949,6 +949,7 @@ String ResourceInteractiveLoaderBinary::recognize(FileAccess *p_f) { } else if (header[0]!='R' || header[1]!='S' || header[2]!='R' || header[3]!='C') { //not normal + error=ERR_FILE_UNRECOGNIZED; return ""; } diff --git a/core/message_queue.cpp b/core/message_queue.cpp index a9c49fbef2f4..dbf6217dc2d3 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -378,11 +378,12 @@ void MessageQueue::flush() { } } - message->~Message(); read_pos+=sizeof(Message); if (message->type!=TYPE_NOTIFICATION) read_pos+=sizeof(Variant)*message->args; + message->~Message(); + _THREAD_SAFE_UNLOCK_ } diff --git a/core/object.cpp b/core/object.cpp index 692010b1b706..b40f4ec1512a 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 * 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