[gnome-software/wip/kalev/crash-when-quickly-closing-update-dialog] update dialog: Avoid crashing when the dialog is quickly closed
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/kalev/crash-when-quickly-closing-update-dialog] update dialog: Avoid crashing when the dialog is quickly closed
- Date: Fri, 3 May 2019 13:52:04 +0000 (UTC)
commit 707197609beb014402701b99a4541ca2ef831b81
Author: Kalev Lember <klember redhat com>
Date: Fri May 3 15:37:05 2019 +0200
update dialog: Avoid crashing when the dialog is quickly closed
Be more careful to avoid dereferencing priv variables in an async
callback handler, which can be called when the dialog is in dispose and
the priv variables have all already been cleared to NULL.
Note that this needs fixing in many more places, but this particular
crash is a top F30 crasher.
https://bugzilla.redhat.com/show_bug.cgi?id=1634075
src/gs-update-dialog.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 36b9beb5..70b7b904 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -245,19 +245,21 @@ get_installed_updates_cb (GsPluginLoader *plugin_loader,
g_autoptr(GsAppList) list = NULL;
g_autoptr(GError) error = NULL;
- gs_stop_spinner (GTK_SPINNER (dialog->spinner));
-
/* get the results */
list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
- if (list == NULL) {
- if (g_error_matches (error,
- GS_PLUGIN_ERROR,
- GS_PLUGIN_ERROR_CANCELLED)) {
- /* This should only ever happen while the dialog is being closed */
- g_debug ("get installed updates cancelled");
- return;
- }
+ /* if we're in teardown, short-circuit and return immediately without
+ * dereferencing priv variables */
+ if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+ dialog->spinner == NULL) {
+ g_debug ("get installed updates cancelled");
+ return;
+ }
+
+ gs_stop_spinner (GTK_SPINNER (dialog->spinner));
+
+ /* error */
+ if (list == NULL) {
g_warning ("failed to get installed updates: %s", error->message);
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "empty");
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]