Merge lp:~mvo/software-center/lp964433 into lp:software-center

Proposed by Michael Vogt on 2012-03-29
Status: Merged
Merged at revision: 2932
Proposed branch: lp:~mvo/software-center/lp964433
Merge into: lp:software-center
Diff against target: 69 lines (+16/-3)
2 files modified
softwarecenter/ui/gtk3/models/appstore2.py (+4/-1)
softwarecenter/ui/gtk3/views/appview.py (+12/-2)
To merge this branch: bzr merge lp:~mvo/software-center/lp964433
Reviewer Review Type Date Requested Status
Gary Lasker (community) 2012-03-29 Approve on 2012-03-30
Review via email: mp+99924@code.launchpad.net

Description of the change

This branch fixes bug #964433.

It turns out that the bug is that:
- in appview.py we call model.set_from_matches()
- this will load a initial batch of rows and the add empty placeholder rows
- because the apptreeview has a _cell_data_func the rows are requesting data
- this causes load_range to be run and that will load the documents that were meant to be empty and loaded on demand

The fix is to disconnect the model first and then after its updated set it again.

To post a comment you must log in.
Gary Lasker (gary-lasker) wrote :

This is a tricky one, well done! Thanks mvo.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/models/appstore2.py'
2--- softwarecenter/ui/gtk3/models/appstore2.py 2012-03-16 10:44:05 +0000
3+++ softwarecenter/ui/gtk3/models/appstore2.py 2012-03-29 12:42:33 +0000
4@@ -409,6 +409,7 @@
5 """ set the content of the liststore based on a list of
6 xapian.MSetItems
7 """
8+ LOG.debug("set_from_matches len(matches)='%s'" % len(matches))
9 self.current_matches = matches
10 n_matches = len(matches)
11 if n_matches == 0:
12@@ -432,6 +433,7 @@
13 self.buffer_icons()
14
15 def load_range(self, indices, step):
16+ LOG.debug("load_range: %s %s" % (indices, step))
17 db = self.db.xapiandb
18 matches = self.current_matches
19
20@@ -446,7 +448,8 @@
21 for i in range(start, end):
22 try:
23 row_content = self[(i,)][0]
24- except IndexError:
25+ except IndexError as e:
26+ LOG.warn("failed to load rows: '%s'" % e)
27 break
28
29 if row_content:
30
31=== modified file 'softwarecenter/ui/gtk3/views/appview.py'
32--- softwarecenter/ui/gtk3/views/appview.py 2012-03-14 16:34:56 +0000
33+++ softwarecenter/ui/gtk3/views/appview.py 2012-03-29 12:42:33 +0000
34@@ -176,13 +176,16 @@
35 def set_model(self, model):
36 self.tree_view.set_model(model)
37
38+ def get_model(self):
39+ return self.tree_view.appmodel
40+
41 def display_matches(self, matches, is_search=False):
42 # FIXME: installedpane handles display of the trees intimately,
43 # so for the time being lets just return None in the case of our
44 # TreeView displaying an AppTreeStore ... ;(
45 # ... also we dont currently support user sorting in the
46 # installedview, so issue is somewhat moot for the time being...
47- if isinstance(self.tree_view.appmodel, AppTreeStore):
48+ if isinstance(self.get_model(), AppTreeStore):
49 LOG.debug("display_matches called on AppTreeStore, ignoring")
50 return
51
52@@ -197,9 +200,16 @@
53 not self.user_defined_sort_method):
54 self.set_sort_method_with_no_signal(self._SORT_BY_TOP_RATED)
55
56- model = self.tree_view.appmodel
57+ model = self.get_model()
58+ # disconnect the model from the view before running
59+ # set_from_matches to ensure that the _cell_data_func_cb is not
60+ # run when the placeholder items are set, otherwise the purpose
61+ # of the "load-on-demand" is gone and it leads to bugs like
62+ # LP: #964433
63+ self.set_model(None)
64 if model:
65 model.set_from_matches(matches)
66+ self.set_model(model)
67 self.user_defined_sort_method = False
68
69 self.tree_view_scroll.get_vadjustment().set_lower(self.vadj)

Subscribers

People subscribed via source and target branches