Merge lp:~indicator-applet-developers/hud/simplify-app-source-refcounting into lp:hud/13.10

Proposed by Pete Woods
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 338
Merged at revision: 338
Proposed branch: lp:~indicator-applet-developers/hud/simplify-app-source-refcounting
Merge into: lp:hud/13.10
Diff against target: 167 lines (+39/-45)
2 files modified
src/application-list.c (+35/-44)
src/application-source.c (+4/-1)
To merge this branch: bzr merge lp:~indicator-applet-developers/hud/simplify-app-source-refcounting
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Antti Kaijanmäki (community) Approve
Indicator Applet Developers Pending
Review via email: mp+190986@code.launchpad.net

Commit message

Fix the ref counting of application sources

The application sources are now entirely owned by the application-list's hash table

Description of the change

Fix the ref counting of application sources

The application sources are now entirely owned by the application-list's hash table

To post a comment you must log in.
338. By Pete Woods

Fix a missing clear

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

approved.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/application-list.c'
--- src/application-list.c 2013-10-11 15:58:52 +0000
+++ src/application-list.c 2013-10-14 15:48:19 +0000
@@ -229,11 +229,9 @@
229229
230 if (self->priv->used_source != NULL) {230 if (self->priv->used_source != NULL) {
231 hud_source_unuse(self->priv->used_source);231 hud_source_unuse(self->priv->used_source);
232 g_clear_object(&self->priv->used_source);232 self->priv->used_source = NULL;
233 }233 }
234234
235 g_clear_object(&self->priv->last_focused_main_stage_source);
236
237 if (self->priv->matcher_app_sig != 0 && self->priv->window_stack != NULL) {235 if (self->priv->matcher_app_sig != 0 && self->priv->window_stack != NULL) {
238 g_signal_handler_disconnect(self->priv->window_stack, self->priv->matcher_app_sig);236 g_signal_handler_disconnect(self->priv->window_stack, self->priv->matcher_app_sig);
239 }237 }
@@ -353,7 +351,7 @@
353 }351 }
354352
355 /* Clear the last source, as we've obviously changed */353 /* Clear the last source, as we've obviously changed */
356 g_clear_object(&list->priv->last_focused_main_stage_source);354 list->priv->last_focused_main_stage_source = NULL;
357355
358 HudApplicationSource *source = application_info_to_source(list, window);356 HudApplicationSource *source = application_info_to_source(list, window);
359357
@@ -383,7 +381,7 @@
383 return;381 return;
384 }382 }
385383
386 list->priv->last_focused_main_stage_source = g_object_ref(source);384 list->priv->last_focused_main_stage_source = source;
387385
388 hud_application_source_focus(source, window, window);386 hud_application_source_focus(source, window, window);
389387
@@ -399,6 +397,7 @@
399static void397static void
400view_opened (DBusWindowStack * window_stack, guint window_id, const gchar *app_id, gpointer user_data)398view_opened (DBusWindowStack * window_stack, guint window_id, const gchar *app_id, gpointer user_data)
401{399{
400 g_debug("view_opened(%d, %s)", window_id, app_id);
402 HudApplicationList * list = HUD_APPLICATION_LIST(user_data);401 HudApplicationList * list = HUD_APPLICATION_LIST(user_data);
403402
404 HudWindowInfo *window = hud_window_info_new(list->priv->window_stack,403 HudWindowInfo *window = hud_window_info_new(list->priv->window_stack,
@@ -421,44 +420,37 @@
421static void420static void
422view_closed (DBusWindowStack * window_stack, guint window_id, const gchar *app_id, gpointer user_data)421view_closed (DBusWindowStack * window_stack, guint window_id, const gchar *app_id, gpointer user_data)
423{422{
424 g_debug("Closing Window: %d", window_id);423 g_debug("view_closed(%d, %s)", window_id, app_id);
425424
426 HudApplicationList * list = HUD_APPLICATION_LIST(user_data);425 HudApplicationList * list = HUD_APPLICATION_LIST(user_data);
427426 HudSource *source = source_get(HUD_SOURCE(user_data), app_id);
428 GList * sources = g_hash_table_get_values(list->priv->applications);427
429 GList * lsource = NULL;428 if (source == NULL) {
430429 g_warning("Window closed for unknown app: %s", app_id);
431 for (lsource = sources; lsource != NULL; lsource = g_list_next(lsource)) {430 return;
432 HudApplicationSource * appsource = HUD_APPLICATION_SOURCE(lsource->data);431 }
433 if (appsource == NULL) continue;432
434433 HudApplicationSource *appsource = HUD_APPLICATION_SOURCE(source);
435 if (hud_application_source_has_xid(appsource, window_id)) {434
436 hud_application_source_window_closed(appsource, window_id);435 if (hud_application_source_has_xid(appsource, window_id)) {
437 }436 hud_application_source_window_closed(appsource, window_id);
438437 }
439 /* If the application source has become empty it means that it438
440 * the correspongind app has terminated and it's time to do the439 /* If the application source has become empty it means that
441 * cleanup.440 * the corresponding app has terminated and it's time to do the
442 */441 * cleanup.
443 if (hud_application_source_is_empty (appsource)) {442 */
444 if ((gpointer)appsource == (gpointer)list->priv->used_source) {443 if (hud_application_source_is_empty (appsource)) {
445 hud_source_unuse(HUD_SOURCE(appsource));444 if ((gpointer)appsource == (gpointer)list->priv->used_source) {
446 g_clear_object(&list->priv->used_source);445 hud_source_unuse(HUD_SOURCE(appsource));
447 }446 list->priv->used_source = NULL;
448447 }
449 gchar * id = g_strdup(hud_application_source_get_id(appsource));448
450449 g_debug("Removing application %s", app_id);
451 g_debug("Removing application %s", id);450 g_hash_table_remove(list->priv->applications, app_id);
452 g_hash_table_remove(list->priv->applications, id);451 }
453 g_free(id);452
454 }453 hud_source_changed(HUD_SOURCE(list));
455
456 hud_source_changed(HUD_SOURCE(list));
457 }
458
459
460
461 return;
462}454}
463455
464/* Source interface using this source */456/* Source interface using this source */
@@ -480,10 +472,9 @@
480472
481 if (list->priv->used_source != NULL) {473 if (list->priv->used_source != NULL) {
482 hud_source_unuse(list->priv->used_source);474 hud_source_unuse(list->priv->used_source);
483 g_clear_object(&list->priv->used_source);
484 }475 }
485476
486 list->priv->used_source = g_object_ref(source);477 list->priv->used_source = HUD_SOURCE(source);
487478
488 hud_source_use(HUD_SOURCE(source));479 hud_source_use(HUD_SOURCE(source));
489480
@@ -500,7 +491,7 @@
500 g_return_if_fail(list->priv->used_source != NULL);491 g_return_if_fail(list->priv->used_source != NULL);
501492
502 hud_source_unuse(list->priv->used_source);493 hud_source_unuse(list->priv->used_source);
503 g_clear_object(&list->priv->used_source);494 list->priv->used_source = NULL;
504495
505 return;496 return;
506}497}
507498
=== modified file 'src/application-source.c'
--- src/application-source.c 2013-10-09 13:24:58 +0000
+++ src/application-source.c 2013-10-14 15:48:19 +0000
@@ -166,6 +166,8 @@
166{166{
167 HudApplicationSource * self = HUD_APPLICATION_SOURCE(object);167 HudApplicationSource * self = HUD_APPLICATION_SOURCE(object);
168168
169 g_debug("hud_application_source_dispose %s", self->priv->app_id);
170
169 if (self->priv->skel != NULL) {171 if (self->priv->skel != NULL) {
170 g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(self->priv->skel));172 g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(self->priv->skel));
171 g_clear_object(&self->priv->skel);173 g_clear_object(&self->priv->skel);
@@ -418,6 +420,8 @@
418HudApplicationSource *420HudApplicationSource *
419hud_application_source_new_for_id (const gchar * id)421hud_application_source_new_for_id (const gchar * id)
420{422{
423 g_debug("hud_application_source_new_for_id: %s", id);
424
421 HudApplicationSource * source = g_object_new(HUD_TYPE_APPLICATION_SOURCE, NULL);425 HudApplicationSource * source = g_object_new(HUD_TYPE_APPLICATION_SOURCE, NULL);
422426
423 source->priv->app_id = g_strdup(id);427 source->priv->app_id = g_strdup(id);
@@ -521,7 +525,6 @@
521 connection_watcher_t * watcher = g_hash_table_lookup(app->priv->connections, sender);525 connection_watcher_t * watcher = g_hash_table_lookup(app->priv->connections, sender);
522 if (watcher == NULL) {526 if (watcher == NULL) {
523 watcher = g_new0(connection_watcher_t, 1);527 watcher = g_new0(connection_watcher_t, 1);
524 g_object_ref(app);
525 watcher->watch = g_bus_watch_name_on_connection(session, sender, G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, connection_lost, app, NULL);528 watcher->watch = g_bus_watch_name_on_connection(session, sender, G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, connection_lost, app, NULL);
526 g_hash_table_insert(app->priv->connections, g_strdup(sender), watcher);529 g_hash_table_insert(app->priv->connections, g_strdup(sender), watcher);
527 }530 }

Subscribers

People subscribed via source and target branches

to all changes: