Simplify use of GCancellable

g_cancellable_cancell can be called without checking for a NULL value.
Use g_clear_object instead of g_object_unref
This commit is contained in:
Robert Ancell 2018-05-31 10:16:54 +12:00 committed by Georges Basile Stavracas Neto
parent dd61d98ec5
commit a64ef75ad7
9 changed files with 23 additions and 54 deletions

View file

@ -75,11 +75,8 @@ cc_search_locations_dialog_init (CcSearchLocationsDialog *self)
static void
place_free (Place * p)
{
if (p->cancellable != NULL)
{
g_cancellable_cancel (p->cancellable);
g_object_unref (p->cancellable);
}
g_cancellable_cancel (p->cancellable);
g_clear_object (&p->cancellable);
g_object_unref (p->location);
g_free (p->display_name);

View file

@ -663,8 +663,7 @@ cc_search_panel_dispose (GObject *object)
{
CcSearchPanel *self = CC_SEARCH_PANEL (object);
if (self->load_cancellable != NULL)
g_cancellable_cancel (self->load_cancellable);
g_cancellable_cancel (self->load_cancellable);
g_clear_object (&self->load_cancellable);
G_OBJECT_CLASS (cc_search_panel_parent_class)->dispose (object);