Skip to content

Commit

Permalink
-Support for changing fonts
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
reduz committed Apr 5, 2014
1 parent 35b84d2 commit 9f33134
Show file tree
Hide file tree
Showing 47 changed files with 1,492 additions and 161 deletions.
7 changes: 7 additions & 0 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions core/bind/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}

Expand Down
3 changes: 2 additions & 1 deletion core/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_

}
Expand Down
54 changes: 52 additions & 2 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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) {

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);

}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1536,6 +1581,11 @@ Object::Object() {
_edited=false;
#endif

#ifdef DEBUG_ENABLED
_lock_index.init(1);
#endif



}

Expand Down
8 changes: 6 additions & 2 deletions core/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ class Object {
Connection(const Variant& p_variant);
};
private:

#ifdef DEBUG_ENABLED
friend class _ObjectDebugLock;
#endif
friend bool predelete_handler(Object*);
friend void postinitialize_handler(Object*);

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ friend class Main;
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);
Expand Down

0 comments on commit 9f33134

Please sign in to comment.