Merge pull request #43053 from Ev1lbl0w/bugfix-shell-open

Changed shell_open behaviour
This commit is contained in:
Rémi Verschelde 2020-10-28 09:17:57 +01:00 committed by GitHub
commit 765b0a0f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,18 +123,39 @@ String OS_LinuxBSD::get_name() const {
Error OS_LinuxBSD::shell_open(String p_uri) { Error OS_LinuxBSD::shell_open(String p_uri) {
Error ok; Error ok;
int err_code;
List<String> args; List<String> args;
args.push_back(p_uri); args.push_back(p_uri);
ok = execute("xdg-open", args, false);
if (ok == OK) { // Agnostic
ok = execute("xdg-open", args, true, nullptr, nullptr, &err_code);
if (ok == OK && !err_code) {
return OK;
} else if (err_code == 2) {
return ERR_FILE_NOT_FOUND;
}
// GNOME
args.push_front("open"); // The command is `gio open`, so we need to add it to args
ok = execute("gio", args, true, nullptr, nullptr, &err_code);
if (ok == OK && !err_code) {
return OK;
} else if (err_code == 2) {
return ERR_FILE_NOT_FOUND;
}
args.pop_front();
ok = execute("gvfs-open", args, true, nullptr, nullptr, &err_code);
if (ok == OK && !err_code) {
return OK;
} else if (err_code == 2) {
return ERR_FILE_NOT_FOUND;
}
// KDE
ok = execute("kde-open5", args, true, nullptr, nullptr, &err_code);
if (ok == OK && !err_code) {
return OK; return OK;
} }
ok = execute("gnome-open", args, false); ok = execute("kde-open", args, true, nullptr, nullptr, &err_code);
if (ok == OK) { return !err_code ? ok : FAILED;
return OK;
}
ok = execute("kde-open", args, false);
return ok;
} }
bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) { bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) {