-
Notifications
You must be signed in to change notification settings - Fork 0
/
libfm-qt-0.13.1-check-if-app-exists-before-opening.patch
45 lines (43 loc) · 1.96 KB
/
libfm-qt-0.13.1-check-if-app-exists-before-opening.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 4923f860094787d14052e9dc416c9388ff1bb53b Mon Sep 17 00:00:00 2001
From: Tsu Jan <[email protected]>
Date: Thu, 7 Jun 2018 06:10:37 +0430
Subject: [PATCH] Check if the opening app exists before using it
Also, show an error message if there's no app.
---
src/core/basicfilelauncher.cpp | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/core/basicfilelauncher.cpp b/src/core/basicfilelauncher.cpp
index 8390531..2c7f00e 100644
--- a/src/core/basicfilelauncher.cpp
+++ b/src/core/basicfilelauncher.cpp
@@ -256,18 +256,25 @@ FilePath BasicFileLauncher::handleShortcut(const FileInfoPtr& fileInfo, GAppLaun
|| strcmp(scheme.get(), "trash") == 0
|| strcmp(scheme.get(), "network") == 0
|| strcmp(scheme.get(), "computer") == 0) {
- return FilePath::fromUri(fileInfo->target().c_str());
+ return FilePath::fromUri(target.c_str());
}
else {
// ask gio to launch the default handler for the uri scheme
- GAppInfoPtr app{g_app_info_get_default_for_uri_scheme(scheme.get()), false};
- FilePathList uris{FilePath::fromUri(fileInfo->target().c_str())};
- launchWithApp(app.get(), uris, ctx);
+ if(GAppInfoPtr app{g_app_info_get_default_for_uri_scheme(scheme.get()), false}) {
+ FilePathList uris{FilePath::fromUri(target.c_str())};
+ launchWithApp(app.get(), uris, ctx);
+ }
+ else {
+ GErrorPtr err{G_IO_ERROR, G_IO_ERROR_FAILED,
+ QObject::tr("No default application is set to launch '%1'")
+ .arg(target.c_str())};
+ showError(nullptr, err);
+ }
}
}
else {
// see it as a local path
- return FilePath::fromLocalPath(fileInfo->target().c_str());
+ return FilePath::fromLocalPath(target.c_str());
}
return FilePath();
}