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

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

Description of the change

The latest unmerged (two) revisions of this branch do the following:

1) Actually allow an AppStore to be deleted (this would never happen as some callbacks were still connected to signals, even when explicitly calling "del [store]"). To check that the AppStore is now actually deleted, one may add a dummy "__del__" method that e.g. prints a debug message.

2) Remove a useless call to AppView.set_model(): passing it None will do nothing anyway.

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

Nice work, thanks Olivier!

review: Approve

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 16:37:28 +0000
4@@ -117,7 +117,7 @@
5 self.icons = icons
6 self.icon_size = icon_size or self.ICON_SIZE
7 # invalidate the cache on icon theme changes
8- self.icons.connect("changed", lambda theme: _app_icon_cache.clear())
9+ self.icons.connect("changed", self._clear_app_icon_cache)
10 self._appicon_missing_icon = self.icons.load_icon(MISSING_APP_ICON, self.icon_size, 0)
11 self.apps = []
12 # this is used to re-set the cursor
13@@ -203,6 +203,9 @@
14 self._existing_apps = None
15 self._installable_apps = None
16
17+ def _clear_app_icon_cache(self, theme):
18+ _app_icon_cache.clear()
19+
20 # internal API
21 def _append_app(self, app):
22 """ append a application to the current store, keep
23@@ -249,6 +252,12 @@
24
25 # external API
26 def clear(self):
27+ """Clear the store and disconnect all callbacks to allow it to be
28+ deleted."""
29+ self.backend.disconnect_by_func(self._on_transaction_finished)
30+ self.backend.disconnect_by_func(self._on_transaction_started)
31+ self.backend.disconnect_by_func(self._on_transaction_progress_changed)
32+ self.icons.disconnect_by_func(self._clear_app_icon_cache)
33 self.apps = []
34 self.app_index_map.clear()
35 self.pkgname_index_map.clear()
36@@ -289,7 +298,6 @@
37
38 # Re-claim the memory used by the new appstore
39 appstore.clear()
40- del appstore
41
42 def _refresh_contents_data(self):
43 # Quantitative data on stored packages. This generates the information.
44
45=== modified file 'softwarecenter/view/channelpane.py'
46--- softwarecenter/view/channelpane.py 2010-05-21 05:31:19 +0000
47+++ softwarecenter/view/channelpane.py 2010-05-28 16:37:28 +0000
48@@ -100,7 +100,6 @@
49 old_model = self.app_view.get_model()
50 if old_model is not None:
51 old_model.active = False
52- self.app_view.set_model(None)
53 gobject.idle_add(self._make_new_model, query, self.refresh_seq_nr)
54 return False
55