Merge lp:~mhr3/libunity/fix-sources-update into lp:libunity

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 128
Merged at revision: 128
Proposed branch: lp:~mhr3/libunity/fix-sources-update
Merge into: lp:libunity
Diff against target: 27 lines (+6/-1)
1 file modified
src/unity-lens-private.vala (+6/-1)
To merge this branch: bzr merge lp:~mhr3/libunity/fix-sources-update
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+98436@code.launchpad.net

Commit message

Make sure all scopes are updated when the filtering state of sources filter changes

Description of the change

Make sure all scopes are updated when the filtering state of sources filter changes

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looking correct.

I was pondering for quite a while if we needed tests for this. I came to the conclusion that we didn't because upon inspecting the code the only line that changes the logic is an extra or-clause, which can only lead us to updating the scopes more often. Not to, fx, not updating them.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-lens-private.vala'
2--- src/unity-lens-private.vala 2012-02-28 15:03:20 +0000
3+++ src/unity-lens-private.vala 2012-03-20 15:37:36 +0000
4@@ -404,17 +404,22 @@
5 /* this is called when unity changes the filter model */
6 var temp = new CheckOptionFilter (_sources.id, _sources.display_name,
7 _sources.icon_hint, _sources.collapsed);
8+ temp.filtering = model.get_bool (iter, FilterColumn.FILTERING);
9 var properties = model.get_value (iter, FilterColumn.RENDERER_STATE);
10 temp.update (properties);
11
12 var updated_scopes = new Gee.HashSet<string> ();
13+ bool force_update = false;
14+
15+ /* if the filtering state was toggled, we need to update all scopes */
16+ if (temp.filtering != _sources.filtering) force_update = true;
17
18 /* get a list of scopes whose sources changed */
19 foreach (var filter_option in temp.options)
20 {
21 FilterOption? current_value = _sources.get_option (filter_option.id);
22 if (current_value == null) continue;
23- if (current_value.active != filter_option.active)
24+ if (force_update || current_value.active != filter_option.active)
25 {
26 string[] tokens = filter_option.id.split (":", 2);
27 updated_scopes.add (tokens[0]);

Subscribers

People subscribed via source and target branches