Merge lp:~3v1n0/bamf/view-incremental-children into lp:bamf

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 570
Merged at revision: 548
Proposed branch: lp:~3v1n0/bamf/view-incremental-children
Merge into: lp:bamf
Diff against target: 98 lines (+30/-8)
1 file modified
lib/libbamf/bamf-view.c (+30/-8)
To merge this branch: bzr merge lp:~3v1n0/bamf/view-incremental-children
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone (community) Approve
Review via email: mp+169226@code.launchpad.net

Commit message

BamfView: use incremental children caching, delete them only when daemon stops

Each view used to cleanup the cached children every time a new one was added or
removed. This was needed at the dbus-glib times to handle the case of bamfdaemon
restart, but now we can handle this nicely, clening the children up only when this
happens.

Description of the change

Don't do unneded dbus-calls when the signals are already informing us about view's children changes.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/libbamf/bamf-view.c'
2--- lib/libbamf/bamf-view.c 2013-06-13 12:52:04 +0000
3+++ lib/libbamf/bamf-view.c 2013-06-13 15:01:31 +0000
4@@ -87,7 +87,8 @@
5 gchar *local_name;
6 gboolean is_closed;
7 gboolean sticky;
8- GList *cached_children;};
9+ GList *cached_children;
10+};
11
12 static void bamf_view_unset_proxy (BamfView *self);
13
14@@ -108,6 +109,7 @@
15 GList *results = NULL;
16 GError *error = NULL;
17 BamfViewPrivate *priv;
18+ BamfView *child;
19
20 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
21
22@@ -136,8 +138,12 @@
23
24 for (i = len-1; i >= 0; --i)
25 {
26- view = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]);
27- results = g_list_prepend (results, g_object_ref (view));
28+ child = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]);
29+
30+ if (BAMF_IS_VIEW (child))
31+ {
32+ results = g_list_prepend (results, g_object_ref (child));
33+ }
34 }
35
36 priv->cached_children = results;
37@@ -470,16 +476,18 @@
38 view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
39 priv = self->priv;
40
41+ g_return_if_fail (BAMF_IS_VIEW (view));
42+
43 if (BAMF_IS_TAB (view))
44 {
45 g_signal_connect (view, "notify::xid",
46 G_CALLBACK (bamf_view_child_xid_changed), self);
47 }
48
49- if (priv->cached_children)
50+ if (!g_list_find (priv->cached_children, view))
51 {
52- g_list_free_full (priv->cached_children, g_object_unref);
53- priv->cached_children = NULL;
54+ g_object_ref (view);
55+ priv->cached_children = g_list_prepend (priv->cached_children, view);
56 }
57
58 g_signal_emit (G_OBJECT (self), view_signals[CHILD_ADDED], 0, view);
59@@ -490,16 +498,24 @@
60 {
61 BamfView *view;
62 BamfViewPrivate *priv;
63+
64 view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
65 priv = self->priv;
66
67+ g_return_if_fail (BAMF_IS_VIEW (view));
68+
69 if (BAMF_IS_TAB (view))
70 g_signal_handlers_disconnect_by_func (view, bamf_view_on_child_added, self);
71
72 if (priv->cached_children)
73 {
74- g_list_free_full (priv->cached_children, g_object_unref);
75- priv->cached_children = NULL;
76+ GList *l = g_list_find (priv->cached_children, view);
77+
78+ if (l)
79+ {
80+ priv->cached_children = g_list_delete_link (priv->cached_children, l);
81+ g_object_unref (view);
82+ }
83 }
84
85 g_signal_emit (G_OBJECT (self), view_signals[CHILD_REMOVED], 0, view);
86@@ -513,6 +529,12 @@
87
88 if (!name_owner)
89 {
90+ if (self->priv->cached_children)
91+ {
92+ g_list_free_full (self->priv->cached_children, g_object_unref);
93+ self->priv->cached_children = NULL;
94+ }
95+
96 _bamf_view_set_closed (self, TRUE);
97 g_signal_emit (G_OBJECT (self), view_signals[CLOSED], 0);
98 }

Subscribers

People subscribed via source and target branches