|
|
b595e8 |
From 406a8849261e6301a66b7f1ece35051afd828592 Mon Sep 17 00:00:00 2001
|
|
|
b595e8 |
From: Simon McVittie <smcv@collabora.com>
|
|
|
b595e8 |
Date: Sun, 6 Sep 2020 15:32:14 +0100
|
|
|
b595e8 |
Subject: [PATCH] open-uri: Don't crash if there is no default or latest app
|
|
|
b595e8 |
|
|
|
b595e8 |
g_desktop_app_info_new() requires a non-NULL argument.
|
|
|
b595e8 |
|
|
|
b595e8 |
Partially addresses #524.
|
|
|
b595e8 |
|
|
|
b595e8 |
Fixes: 69205f12 "open-uri: Show app chooser when default app does not exist"
|
|
|
b595e8 |
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
|
b595e8 |
---
|
|
|
b595e8 |
src/open-uri.c | 8 +++++---
|
|
|
b595e8 |
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
b595e8 |
|
|
|
b595e8 |
diff --git a/src/open-uri.c b/src/open-uri.c
|
|
|
b595e8 |
index bb63478..f746e64 100644
|
|
|
b595e8 |
--- a/src/open-uri.c
|
|
|
b595e8 |
+++ b/src/open-uri.c
|
|
|
b595e8 |
@@ -555,6 +555,8 @@ app_exists (const char *app_id)
|
|
|
b595e8 |
{
|
|
|
b595e8 |
g_autoptr(GDesktopAppInfo) info = NULL;
|
|
|
b595e8 |
|
|
|
b595e8 |
+ g_return_val_if_fail (app_id != NULL, FALSE);
|
|
|
b595e8 |
+
|
|
|
b595e8 |
info = g_desktop_app_info_new (app_id);
|
|
|
b595e8 |
return (info != NULL);
|
|
|
b595e8 |
}
|
|
|
b595e8 |
@@ -667,13 +669,13 @@ handle_open_in_thread_func (GTask *task,
|
|
|
b595e8 |
|
|
|
b595e8 |
/* collect all the information */
|
|
|
b595e8 |
find_recommended_choices (scheme, content_type, &default_app, &choices, &n_choices);
|
|
|
b595e8 |
- if (!app_exists (default_app))
|
|
|
b595e8 |
+ if (default_app != NULL && !app_exists (default_app))
|
|
|
b595e8 |
g_clear_pointer (&default_app, g_free);
|
|
|
b595e8 |
use_default_app = should_use_default_app (scheme, content_type);
|
|
|
b595e8 |
get_latest_choice_info (app_id, content_type,
|
|
|
b595e8 |
&latest_id, &latest_count, &latest_threshold,
|
|
|
b595e8 |
&ask_for_content_type);
|
|
|
b595e8 |
- if (!app_exists (latest_id))
|
|
|
b595e8 |
+ if (latest_id != NULL && !app_exists (latest_id))
|
|
|
b595e8 |
g_clear_pointer (&latest_id, g_free);
|
|
|
b595e8 |
|
|
|
b595e8 |
skip_app_chooser = FALSE;
|
|
|
b595e8 |
@@ -729,7 +731,7 @@ handle_open_in_thread_func (GTask *task,
|
|
|
b595e8 |
app = latest_id;
|
|
|
b595e8 |
else if (default_app != NULL)
|
|
|
b595e8 |
app = default_app;
|
|
|
b595e8 |
- else if (choices && app_exists (choices[0]))
|
|
|
b595e8 |
+ else if (n_choices > 0 && app_exists (choices[0]))
|
|
|
b595e8 |
app = choices[0];
|
|
|
b595e8 |
|
|
|
b595e8 |
if (app)
|