aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2021-12-20 19:14:31 -0500
committerScott Murray <scott.murray@konsulko.com>2021-12-20 19:31:57 -0500
commit365f6130c025e2a034ecabed95ee59af08a1613a (patch)
tree2098078321e14c69c5fa361e54b6f09382642dcb
parentd388e92df803d0c8a7b0c18762b0900796e348d1 (diff)
Handle XDG_DATA_DIRS not being setmarlin_12.91.0marlin/12.91.012.91.0
Tweak logic in app_launcher_update_applications_list to avoid crashing when XDG_DATA_DIRS is not set in the environment. Bug-AGL: SPEC-4160 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ia5494f3482a979cbdb22d89e3777d426d4750d4f
-rw-r--r--src/app_launcher.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/app_launcher.c b/src/app_launcher.c
index 9bb95a4..ddb55c8 100644
--- a/src/app_launcher.c
+++ b/src/app_launcher.c
@@ -51,9 +51,13 @@ G_DEFINE_TYPE_WITH_CODE(AppLauncher, app_launcher,
static void app_launcher_update_applications_list(AppLauncher *self)
{
g_autoptr(GList) app_list = g_app_info_get_all();
- g_auto(GStrv) dirlist = g_strsplit(getenv("XDG_DATA_DIRS"), ":", -1);
+ g_auto(GStrv) dirlist = NULL;
guint len = g_list_length(app_list);
+ char *xdg_data_dirs = getenv("XDG_DATA_DIRS");
+ if (xdg_data_dirs)
+ dirlist = g_strsplit(getenv("XDG_DATA_DIRS"), ":", -1);
+
for (guint i = 0; i < len; i++) {
GAppInfo *appinfo = g_list_nth_data(app_list, i);
const gchar *desktop_id = g_app_info_get_id(appinfo);
@@ -102,16 +106,16 @@ static void app_launcher_update_applications_list(AppLauncher *self)
* - its .desktop file contains a "DBusActivatable=true" line
* - it provides a corresponding D-Bus service file
*/
+
+ /* Default to non-DBus-activatable */
+ dbus_activated = FALSE;
if (g_desktop_app_info_get_boolean(desktop_info,
G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE)) {
dbus_activated = TRUE;
- } else {
+ } else if (dirlist) {
const gchar *desktop_filename = g_desktop_app_info_get_filename(desktop_info);
g_autofree gchar *service_file = g_strconcat(app_id, ".service", NULL);
- /* Default to non-DBus-activatable */
- dbus_activated = FALSE;
-
for (GStrv xdg_data_dir = dirlist; *xdg_data_dir != NULL ; xdg_data_dir++) {
g_autofree gchar *service_path = NULL;
@@ -136,7 +140,7 @@ static void app_launcher_update_applications_list(AppLauncher *self)
* GAppInfo retrieves the icon data but doesn't provide a way to retrieve
* the corresponding file name, so we have to look it up by ourselves.
*/
- if (icon)
+ if (icon && dirlist)
icon_path = applaunchd_utils_get_icon(dirlist, g_icon_to_string(icon));
app_info = app_info_new(app_id, g_app_info_get_name(appinfo),