app-system: Don't assume that gmenu_tree_load_sync() sets error

The function may return FALSE without setting the GError, so don't
assume it is set to prevent a crash in that case. While at it, free
the GError we were leaking before.

https://bugzilla.gnome.org/show_bug.cgi?id=670418
This commit is contained in:
Florian Müllner 2012-02-20 08:33:49 +01:00
parent 097e56f4ab
commit b990ed2c23

View File

@ -320,7 +320,15 @@ on_apps_tree_changed_cb (GMenuTree *tree,
if (!gmenu_tree_load_sync (self->priv->apps_tree, &error))
{
g_warning ("Failed to load apps: %s", error->message);
if (error)
{
g_warning ("Failed to load apps: %s", error->message);
g_error_free (error);
}
else
{
g_warning ("Failed to load apps");
}
return;
}
@ -411,7 +419,15 @@ on_settings_tree_changed_cb (GMenuTree *tree,
g_hash_table_remove_all (self->priv->setting_id_to_app);
if (!gmenu_tree_load_sync (self->priv->settings_tree, &error))
{
g_warning ("Failed to load settings: %s", error->message);
if (error)
{
g_warning ("Failed to load apps: %s", error->message);
g_error_free (error);
}
else
{
g_warning ("Failed to load apps");
}
return;
}