Merge lp:~osomon/software-center/fix_appstore_update into lp:software-center

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 816
Proposed branch: lp:~osomon/software-center/fix_appstore_update
Merge into: lp:software-center
Diff against target: 33 lines (+6/-1)
2 files modified
softwarecenter/view/appview.py (+5/-1)
softwarecenter/view/channelpane.py (+1/-0)
To merge this branch: bzr merge lp:~osomon/software-center/fix_appstore_update
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+26327@code.launchpad.net

Description of the change

This branch fixes updating an existing AppStore with a new one. There were two issues:

1) Before an update, the model's "active" attribute was set to False to avoid catching signals while being updated, but it was never set back to True afterwards.

2) In the update itself, the internal (package name -> index) map was incorrectly filled with integers instead of lists of integers (and it was not cleared in the first place), leaving it in an inconsisten state.

I'm not aware if there is a bug report for this already, I can file one if needed.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Great catch, thanks a lot, Olivier! I made two small changes when merging, please take a look to make sure you see no problem with them:

 1. Also include a clear() for the app_index_map in the appstore's update() method.
 2. Drop the self.app_view.get_model().active = True in channelpane as that is always initialized when the new appstore is created.

review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the fast review Gary!
Regarding your tweaks:

1) clear()ing the app_index_map is not strictly necessary, as the update of the model is going to update the necessary entries and stale entries are never going to be accessed, but it doesn't hurt either.

2) This isn't correct, because in the case of an update, the existing appstore is updated with the contents of the new appstore, but its 'active' attribute is never re-set to True (the new appstore is deleted afterwards). I think this tweak should be reverted.

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hey Olivier! Thanks for your very-fast review review. :D

Regarding item 1), point taken. I'll leave it for now as I need to look at this area more closely in any case so there will be more work here.

Regarding item 2), I added that back in to trunk. Thanks again!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/view/appview.py'
2--- softwarecenter/view/appview.py 2010-05-27 17:20:33 +0000
3+++ softwarecenter/view/appview.py 2010-05-28 17:11:33 +0000
4@@ -257,12 +257,16 @@
5 """ update this appstore to match data from another """
6 # Updating instead of replacing prevents a distracting white
7 # flash. First, match list of apps.
8+ self.pkgname_index_map.clear()
9 to_update = min(len(self), len(appstore))
10 for i in range(to_update):
11 self.apps[i] = appstore.apps[i]
12 self.row_changed(i, self.get_iter(i))
13 self.app_index_map[self.apps[i]] = i
14- self.pkgname_index_map[self.apps[i].pkgname] = i
15+ pkgname = self.apps[i].pkgname
16+ if pkgname not in self.pkgname_index_map:
17+ self.pkgname_index_map[pkgname] = []
18+ self.pkgname_index_map[pkgname].append(i)
19
20 to_remove = max(0, len(self) - len(appstore))
21 for i in range(to_remove):
22
23=== modified file 'softwarecenter/view/channelpane.py'
24--- softwarecenter/view/channelpane.py 2010-05-21 05:31:19 +0000
25+++ softwarecenter/view/channelpane.py 2010-05-28 17:11:33 +0000
26@@ -121,6 +121,7 @@
27 self.scroll_app_list.window.set_cursor(None)
28 if seq_nr == self.refresh_seq_nr:
29 self.app_view.set_model(new_model)
30+ self.app_view.get_model().active = True
31 self.emit("app-list-changed", len(new_model))
32 else:
33 logging.debug("discarding new model (%s != %s)" % (seq_nr, self.refresh_seq_nr))