From e72717e3738ea7fe1a2a6c9447ad0090bdf297ec Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 17 May 2015 13:11:55 -0300 Subject: properly save external resources, fixes #1924 added API to get scancode names to OS --- core/bind/core_bind.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index cde328bc6f..06b71f05c0 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -5,7 +5,7 @@ #include "io/base64.h" #include "core/globals.h" #include "io/file_access_encrypted.h" - +#include "os/keyboard.h" _ResourceLoader *_ResourceLoader::singleton=NULL; Ref _ResourceLoader::load_interactive(const String& p_path,const String& p_type_hint) { @@ -694,6 +694,20 @@ String _OS::get_custom_level() const { return OS::get_singleton()->get_custom_level(); } + +String _OS::get_scancode_string(uint32_t p_code) const { + + return keycode_get_string(p_code); +} +bool _OS::is_scancode_unicode(uint32_t p_unicode) const { + + return keycode_has_unicode(p_unicode); +} +int _OS::find_scancode_from_string(const String& p_code) const { + + return find_keycode(p_code); +} + _OS *_OS::singleton=NULL; void _OS::_bind_methods() { @@ -810,6 +824,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop); ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause); + ObjectTypeDB::bind_method(_MD("get_scancode_string","code"),&_OS::get_scancode_string); + ObjectTypeDB::bind_method(_MD("is_scancode_unicode","code"),&_OS::is_scancode_unicode); + ObjectTypeDB::bind_method(_MD("find_scancode_from_string","string"),&_OS::find_scancode_from_string); ObjectTypeDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap); -- cgit v1.2.3 From f220183e40cb100cdfb8158c5217076377a62980 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 18 May 2015 12:45:53 -0300 Subject: fix a crash situation when starting a thread and other small fixes --- core/bind/core_bind.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 06b71f05c0..be3ce4f44b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1757,7 +1757,9 @@ _Mutex::~_Mutex(){ void _Thread::_start_func(void *ud) { - _Thread *t=(_Thread*)ud; + Ref<_Thread>* tud=(Ref<_Thread>*)ud; + Ref<_Thread> t=*tud; + memdelete(tud); Variant::CallError ce; const Variant* arg[1]={&t->userdata}; t->ret=t->target_instance->call(t->target_method,arg,1,ce); @@ -1804,9 +1806,11 @@ Error _Thread::start(Object *p_instance,const StringName& p_method,const Variant userdata=p_userdata; active=true; + Ref<_Thread> *ud = memnew( Ref<_Thread>(this) ); + Thread::Settings s; s.priority=(Thread::Priority)p_priority; - thread = Thread::create(_start_func,this,s); + thread = Thread::create(_start_func,ud,s); if (!thread) { active=false; target_method=StringName(); @@ -1867,5 +1871,8 @@ _Thread::_Thread() { _Thread::~_Thread() { + if (active) { + ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..") + } ERR_FAIL_COND(active==true); } -- cgit v1.2.3 From 1e5067759420393344ce439fdea1e80e2983579a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 19 May 2015 23:37:04 -0300 Subject: fixes on sample importing --- core/bind/core_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index be3ce4f44b..128bc94989 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1872,7 +1872,7 @@ _Thread::_Thread() { _Thread::~_Thread() { if (active) { - ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..") + ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running.."); } ERR_FAIL_COND(active==true); } -- cgit v1.2.3