Skip to content

Commit

Permalink
Merge pull request #99694 from dsnopek/android-os-create-instance-ret…
Browse files Browse the repository at this point in the history
…urn-value

Android: `OS.create_instance()` should return `-1` on failure
  • Loading branch information
Repiteo committed Nov 27, 2024
2 parents ed01f5f + 38e0532 commit 150c69c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ class Godot(private val context: Context) {

@Keep
private fun createNewGodotInstance(args: Array<String>): Int {
return primaryHost?.onNewGodotInstanceRequested(args) ?: 0
return primaryHost?.onNewGodotInstanceRequested(args) ?: -1
}

@Keep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public int onNewGodotInstanceRequested(String[] args) {
if (parentHost != null) {
return parentHost.onNewGodotInstanceRequested(args);
}
return 0;
return -1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ default void onGodotRestartRequested(Godot instance) {}
* @return the id of the new instance. See {@code onGodotForceQuit}
*/
default int onNewGodotInstanceRequested(String[] args) {
return 0;
return -1;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions platform/android/os_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,9 @@ Error OS_Android::create_process(const String &p_path, const List<String> &p_arg

Error OS_Android::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) {
int instance_id = godot_java->create_new_godot_instance(p_arguments);
if (instance_id == -1) {
return FAILED;
}
if (r_child_id) {
*r_child_id = instance_id;
}
Expand Down

0 comments on commit 150c69c

Please sign in to comment.