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
=== modified file 'src/unity-lens-private.vala'
--- src/unity-lens-private.vala 2012-02-28 15:03:20 +0000
+++ src/unity-lens-private.vala 2012-03-20 15:37:36 +0000
@@ -404,17 +404,22 @@
404 /* this is called when unity changes the filter model */404 /* this is called when unity changes the filter model */
405 var temp = new CheckOptionFilter (_sources.id, _sources.display_name,405 var temp = new CheckOptionFilter (_sources.id, _sources.display_name,
406 _sources.icon_hint, _sources.collapsed);406 _sources.icon_hint, _sources.collapsed);
407 temp.filtering = model.get_bool (iter, FilterColumn.FILTERING);
407 var properties = model.get_value (iter, FilterColumn.RENDERER_STATE);408 var properties = model.get_value (iter, FilterColumn.RENDERER_STATE);
408 temp.update (properties);409 temp.update (properties);
409410
410 var updated_scopes = new Gee.HashSet<string> ();411 var updated_scopes = new Gee.HashSet<string> ();
412 bool force_update = false;
413
414 /* if the filtering state was toggled, we need to update all scopes */
415 if (temp.filtering != _sources.filtering) force_update = true;
411416
412 /* get a list of scopes whose sources changed */417 /* get a list of scopes whose sources changed */
413 foreach (var filter_option in temp.options)418 foreach (var filter_option in temp.options)
414 {419 {
415 FilterOption? current_value = _sources.get_option (filter_option.id);420 FilterOption? current_value = _sources.get_option (filter_option.id);
416 if (current_value == null) continue;421 if (current_value == null) continue;
417 if (current_value.active != filter_option.active)422 if (force_update || current_value.active != filter_option.active)
418 {423 {
419 string[] tokens = filter_option.id.split (":", 2);424 string[] tokens = filter_option.id.split (":", 2);
420 updated_scopes.add (tokens[0]);425 updated_scopes.add (tokens[0]);

Subscribers

People subscribed via source and target branches