Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Android: Fix EditorSettings not instantiated error when running game

uno198219bbd4ccdd22
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 8cb82e485e3..e9dbcc29dcb 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -549,9 +549,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_godotengine_godot_GodotLib_getRendererIn
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
String editor_setting_value = "";
#ifdef TOOLS_ENABLED
- String godot_setting_key = jstring_to_string(p_setting_key, env);
- Variant editor_setting = EDITOR_GET(godot_setting_key);
- editor_setting_value = (editor_setting.get_type() == Variant::NIL) ? "" : editor_setting;
+ if (EditorSettings::get_singleton() != nullptr) {
+ String godot_setting_key = jstring_to_string(p_setting_key, env);
+ Variant editor_setting = EDITOR_GET(godot_setting_key);
+ editor_setting_value = (editor_setting.get_type() == Variant::NIL) ? "" : editor_setting;
+ }
#else
WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
#endif