Browse Source

Fix Android remote debug not hitting breakpoints

    A change in `Main`'s API is needed. Please read the comment in the diff for an explanation.
Pedro J. Estébanez 8 years ago
parent
commit
2a5ee5dec9
3 changed files with 10 additions and 4 deletions
  1. 5 2
      main/main.cpp
  2. 2 1
      main/main.h
  3. 3 1
      platform/android/java_glue.cpp

+ 5 - 2
main/main.cpp

@@ -69,7 +69,6 @@
 #include "core/io/file_access_zip.h"
 #include "core/io/file_access_zip.h"
 #include "core/io/stream_peer_ssl.h"
 #include "core/io/stream_peer_ssl.h"
 #include "core/io/stream_peer_tcp.h"
 #include "core/io/stream_peer_tcp.h"
-#include "core/os/thread.h"
 #include "main/input_default.h"
 #include "main/input_default.h"
 #include "performance.h"
 #include "performance.h"
 #include "translation.h"
 #include "translation.h"
@@ -886,7 +885,11 @@ error:
 	return ERR_INVALID_PARAMETER;
 	return ERR_INVALID_PARAMETER;
 }
 }
 
 
-Error Main::setup2() {
+Error Main::setup2(Thread::ID p_main_tid_override) {
+
+	if (p_main_tid_override) {
+		Thread::_main_thread_id = p_main_tid_override;
+	}
 
 
 	OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);
 	OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);
 	if (init_use_custom_pos) {
 	if (init_use_custom_pos) {

+ 2 - 1
main/main.h

@@ -34,6 +34,7 @@
 	@author Juan Linietsky <[email protected]>
 	@author Juan Linietsky <[email protected]>
 */
 */
 
 
+#include "core/os/thread.h"
 #include "error_list.h"
 #include "error_list.h"
 #include "typedefs.h"
 #include "typedefs.h"
 
 
@@ -49,7 +50,7 @@ class Main {
 
 
 public:
 public:
 	static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);
 	static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);
-	static Error setup2();
+	static Error setup2(Thread::ID p_main_tid_override = 0);
 	static bool start();
 	static bool start();
 	static bool iteration();
 	static bool iteration();
 	static void cleanup();
 	static void cleanup();

+ 3 - 1
platform/android/java_glue.cpp

@@ -1008,7 +1008,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
 		ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaClassWrapper", java_class_wrapper));
 		ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaClassWrapper", java_class_wrapper));
 		_initialize_java_modules();
 		_initialize_java_modules();
 
 
-		Main::setup2();
+		// Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id,
+		// but for Godot purposes, the main thread is the one running the game loop
+		Main::setup2(Thread::get_caller_id());
 		++step;
 		++step;
 		suspend_mutex->unlock();
 		suspend_mutex->unlock();
 		input_mutex->unlock();
 		input_mutex->unlock();