Merge lp:~apinheiro/unity/bug843280 into lp:unity

Proposed by Alejandro Piñeiro
Status: Merged
Merged at revision: 1696
Proposed branch: lp:~apinheiro/unity/bug843280
Merge into: lp:unity
Diff against target: 79 lines (+24/-20)
2 files modified
services/panel-indicator-accessible.c (+21/-12)
services/panel-root-accessible.c (+3/-8)
To merge this branch: bzr merge lp:~apinheiro/unity/bug843280
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+78271@code.launchpad.net

Description of the change

The error was on the callback for "entry-removed". The accessible object for the indicator maintains a list of the accessible objects for each entry. When a entry is removed this list is updated, and requires to navigate on the list to check which is the entry removed and get the index.

The error was that removed the list, but the loop keep iterating over the list, and with and outdated iterator. The solution was just getting out of the loop and remove the element after that.

I also fixed a leak on two _finalize methods, as those removed the contents but not the list itself, and making things more complex (g_slist_free_full is just one line).

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'services/panel-indicator-accessible.c'
2--- services/panel-indicator-accessible.c 2011-09-02 14:56:07 +0000
3+++ services/panel-indicator-accessible.c 2011-10-05 16:58:24 +0000
4@@ -72,19 +72,30 @@
5 GSList *l;
6 guint count = 0;
7 PanelIndicatorAccessible *pia = PANEL_INDICATOR_ACCESSIBLE (user_data);
8+ gboolean found = FALSE;
9+ AtkObject *accessible = NULL;
10
11- for (l = pia->priv->a11y_children; l != NULL; l = l->next, count++)
12+ for (l = pia->priv->a11y_children; l != NULL; l = g_slist_next (l))
13 {
14- AtkObject *accessible = ATK_OBJECT (l->data);
15+ accessible = ATK_OBJECT (l->data);
16
17 if (entry == panel_indicator_entry_accessible_get_entry (PANEL_INDICATOR_ENTRY_ACCESSIBLE (accessible)))
18 {
19- pia->priv->a11y_children = g_slist_remove (pia->priv->a11y_children, accessible);
20- g_signal_emit_by_name (ATK_OBJECT (pia), "children-changed::remove",
21- count, accessible);
22-
23- g_object_unref (accessible);
24+ found = TRUE;
25+ break;
26 }
27+ else
28+ count++;
29+ }
30+
31+
32+ if (found)
33+ {
34+ pia->priv->a11y_children = g_slist_remove (pia->priv->a11y_children, accessible);
35+ g_signal_emit_by_name (ATK_OBJECT (pia), "children-changed::remove",
36+ count, accessible);
37+
38+ g_object_unref (accessible);
39 }
40 }
41
42@@ -214,12 +225,10 @@
43 g_object_unref (G_OBJECT (pia->priv->indicator));
44 }
45
46- while (pia->priv->a11y_children != NULL)
47+ if (pia->priv->a11y_children != NULL)
48 {
49- AtkObject *accessible = ATK_OBJECT (pia->priv->a11y_children->data);
50-
51- pia->priv->a11y_children = g_slist_remove (pia->priv->a11y_children, accessible);
52- g_object_unref (accessible);
53+ g_slist_free_full(pia->priv->a11y_children, g_object_unref);
54+ pia->priv->a11y_children = NULL;
55 }
56
57 g_signal_handlers_disconnect_by_func (pia->priv->service, on_geometries_changed_cb, pia);
58
59=== modified file 'services/panel-root-accessible.c'
60--- services/panel-root-accessible.c 2011-09-03 16:01:33 +0000
61+++ services/panel-root-accessible.c 2011-10-05 16:58:24 +0000
62@@ -42,15 +42,10 @@
63 {
64 PanelRootAccessible *root = PANEL_ROOT_ACCESSIBLE (object);
65
66- if (root->priv != NULL)
67+ if ((root->priv != NULL) && (root->priv->a11y_children != NULL))
68 {
69- while (root->priv->a11y_children != NULL)
70- {
71- AtkObject *accessible = ATK_OBJECT (root->priv->a11y_children->data);
72-
73- root->priv->a11y_children = g_slist_remove (root->priv->a11y_children, accessible);
74- g_object_unref (accessible);
75- }
76+ g_slist_free_full(root->priv->a11y_children, g_object_unref);
77+ root->priv->a11y_children = NULL;
78 }
79 }
80