summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp5
-rw-r--r--doc/classes/OS.xml4
-rw-r--r--drivers/unix/os_unix.cpp2
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/script_editor_debugger.cpp2
5 files changed, 12 insertions, 9 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 30aaa0e646..d07ba44788 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -481,15 +481,18 @@ Error _OS::shell_open(String p_uri) {
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr) {
OS::ProcessID pid = -2;
+ int exitcode = 0;
List<String> args;
for (int i = 0; i < p_arguments.size(); i++)
args.push_back(p_arguments[i]);
String pipe;
- Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe, NULL, p_read_stderr);
+ Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe, &exitcode, p_read_stderr);
p_output.clear();
p_output.push_back(pipe);
if (err != OK)
return -1;
+ else if (p_blocking)
+ return exitcode;
else
return pid;
}
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 9f61245819..9acddb3115 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -105,11 +105,11 @@
This method has slightly different behavior based on whether the [code]blocking[/code] mode is enabled.
If [code]blocking[/code] is [code]true[/code], the Godot thread will pause its execution while waiting for the process to terminate. The shell output of the process will be written to the [code]output[/code] array as a single string. When the process terminates, the Godot thread will resume execution.
If [code]blocking[/code] is [code]false[/code], the Godot thread will continue while the new process runs. It is not possible to retrieve the shell output in non-blocking mode, so [code]output[/code] will be empty.
- The return value also depends on the blocking mode. When blocking, the method will return -2 (no process ID information is available in blocking mode). When non-blocking, the method returns a process ID, which you can use to monitor the process (and potentially terminate it with [method kill]). If the process forking (non-blocking) or opening (blocking) fails, the method will return [code]-1[/code].
+ The return value also depends on the blocking mode. When blocking, the method will return an exit code of the process. When non-blocking, the method returns a process ID, which you can use to monitor the process (and potentially terminate it with [method kill]). If the process forking (non-blocking) or opening (blocking) fails, the method will return [code]-1[/code] or another exit code.
Example of blocking mode and retrieving the shell output:
[codeblock]
var output = []
- OS.execute("ls", ["-l", "/tmp"], true, output)
+ var exit_code = OS.execute("ls", ["-l", "/tmp"], true, output)
[/codeblock]
Example of non-blocking mode, running another instance of the project and storing its process ID:
[codeblock]
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index bc57c0b8df..80d7a2ccaa 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -314,7 +314,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
int rv = pclose(f);
if (r_exitcode)
- *r_exitcode = rv;
+ *r_exitcode = WEXITSTATUS(rv);
return OK;
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index df1e8005ed..05b50d5dfe 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2365,6 +2365,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
} break;
+ case RUN_PROJECT_DATA_FOLDER: {
+ OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir());
+ } break;
case FILE_EXPLORE_ANDROID_BUILD_TEMPLATES: {
OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().plus_file("android"));
} break;
@@ -2571,8 +2574,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
save_all_scenes();
restart_editor();
} break;
- default: {
- }
}
}
@@ -2605,9 +2606,6 @@ void EditorNode::_tool_menu_option(int p_idx) {
case TOOLS_ORPHAN_RESOURCES: {
orphan_resources->show();
} break;
- case RUN_PROJECT_DATA_FOLDER: {
- OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir());
- } break;
case TOOLS_CUSTOM: {
if (tool_menu->get_item_submenu(p_idx) == "") {
Array params = tool_menu->get_item_metadata(p_idx);
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 6a9dbb103a..e96dfdd7b9 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -423,10 +423,12 @@ void ScriptEditorDebugger::_scene_tree_request() {
int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &nodes, int current_index) {
String filter = EditorNode::get_singleton()->get_scene_tree_dock()->get_filter();
String item_text = nodes[current_index + 1];
+ String item_type = nodes[current_index + 2];
bool keep = filter.is_subsequence_ofi(item_text);
TreeItem *item = inspect_scene_tree->create_item(parent);
item->set_text(0, item_text);
+ item->set_tooltip(0, TTR("Type:") + " " + item_type);
ObjectID id = ObjectID(nodes[current_index + 3]);
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], "");
if (icon.is_valid()) {