summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h2
-rw-r--r--core/io/resource_format_binary.cpp1
-rw-r--r--core/message_queue.cpp3
-rw-r--r--core/object.cpp54
-rw-r--r--core/object.h8
-rw-r--r--core/os/os.cpp5
-rw-r--r--core/os/os.h1
8 files changed, 76 insertions, 5 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1b4ca8151b..e3360a23d2 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 3d03247c07..0084726547 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -117,6 +117,8 @@ public:
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 47f278596b..33f4cafedd 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 a9c49fbef2..dbf6217dc2 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 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
+
+
}
diff --git a/core/object.h b/core/object.h
index 913d837172..6290f9d64b 100644
--- a/core/object.h
+++ b/core/object.h
@@ -331,7 +331,9 @@ public:
Connection(const Variant& p_variant);
};
private:
-
+#ifdef DEBUG_ENABLED
+friend class _ObjectDebugLock;
+#endif
friend bool predelete_handler(Object*);
friend void postinitialize_handler(Object*);
@@ -365,7 +367,9 @@ friend void postinitialize_handler(Object*);
HashMap< StringName, Signal, StringNameHasher> signal_map;
List<Connection> connections;
-
+#ifdef DEBUG_ENABLED
+ SafeRefCount _lock_index;
+#endif
bool _block_signals;
int _predelete_ok;
Set<Object*> change_receptors;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index f678d38f56..65d6ed50b2 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -124,6 +124,11 @@ String OS::get_executable_path() const {
return _execpath;
}
+int OS::get_process_ID() const {
+
+ return -1;
+};
+
uint64_t OS::get_frames_drawn() {
return frames_drawn;
diff --git a/core/os/os.h b/core/os/os.h
index b41bf6ce73..e7fe0cb09e 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -162,6 +162,7 @@ public:
virtual String get_executable_path() const;
virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL)=0;
virtual Error kill(const ProcessID& p_pid)=0;
+ virtual int get_process_ID() const;
virtual Error shell_open(String p_uri);
virtual Error set_cwd(const String& p_cwd);