[gnome-software] Fix a crash when removing an addon
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix a crash when removing an addon
- Date: Fri, 24 Mar 2017 15:25:06 +0000 (UTC)
commit 7c29c90c8b2b16adbce6b6de867730799778b1fd
Author: Richard Hughes <richard hughsie com>
Date: Fri Mar 24 15:02:27 2017 +0000
Fix a crash when removing an addon
This can sometimes be reproduced when searching for keywords during startup.
lib/gs-app.c | 2 +-
lib/gs-self-test.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 0bb6140..e642fe7 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -2872,8 +2872,8 @@ gs_app_remove_addon (GsApp *app, GsApp *addon)
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&app->mutex);
g_return_if_fail (GS_IS_APP (app));
g_return_if_fail (GS_IS_APP (addon));
- g_ptr_array_remove (app->addons, addon);
g_hash_table_remove (app->addons_hash, gs_app_get_id (addon));
+ g_ptr_array_remove (app->addons, addon);
}
/**
diff --git a/lib/gs-self-test.c b/lib/gs-self-test.c
index 8c8e7be..74d3537 100644
--- a/lib/gs-self-test.c
+++ b/lib/gs-self-test.c
@@ -377,6 +377,20 @@ gs_app_unique_id_func (void)
}
static void
+gs_app_addons_func (void)
+{
+ g_autoptr(GsApp) app = gs_app_new ("test.desktop");
+ GsApp *addon;
+
+ /* create, add then drop ref, so @app has the only refcount of addon */
+ addon = gs_app_new ("test.desktop");
+ gs_app_add_addon (app, addon);
+ g_object_unref (addon);
+
+ gs_app_remove_addon (app, addon);
+}
+
+static void
gs_app_func (void)
{
g_autoptr(GsApp) app = NULL;
@@ -485,6 +499,7 @@ main (int argc, char **argv)
g_test_add_func ("/gnome-software/lib/utils{error}", gs_utils_error_func);
g_test_add_func ("/gnome-software/lib/os-release", gs_os_release_func);
g_test_add_func ("/gnome-software/lib/app", gs_app_func);
+ g_test_add_func ("/gnome-software/lib/app{addons}", gs_app_addons_func);
g_test_add_func ("/gnome-software/lib/app{unique-id}", gs_app_unique_id_func);
g_test_add_func ("/gnome-software/lib/app{thread}", gs_app_thread_func);
g_test_add_func ("/gnome-software/lib/plugin", gs_plugin_func);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]