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
=== modified file 'softwarecenter/view/appview.py'
--- softwarecenter/view/appview.py 2010-05-27 17:20:33 +0000
+++ softwarecenter/view/appview.py 2010-05-28 16:37:28 +0000
@@ -117,7 +117,7 @@
117 self.icons = icons117 self.icons = icons
118 self.icon_size = icon_size or self.ICON_SIZE118 self.icon_size = icon_size or self.ICON_SIZE
119 # invalidate the cache on icon theme changes119 # invalidate the cache on icon theme changes
120 self.icons.connect("changed", lambda theme: _app_icon_cache.clear())120 self.icons.connect("changed", self._clear_app_icon_cache)
121 self._appicon_missing_icon = self.icons.load_icon(MISSING_APP_ICON, self.icon_size, 0)121 self._appicon_missing_icon = self.icons.load_icon(MISSING_APP_ICON, self.icon_size, 0)
122 self.apps = []122 self.apps = []
123 # this is used to re-set the cursor123 # this is used to re-set the cursor
@@ -203,6 +203,9 @@
203 self._existing_apps = None203 self._existing_apps = None
204 self._installable_apps = None204 self._installable_apps = None
205205
206 def _clear_app_icon_cache(self, theme):
207 _app_icon_cache.clear()
208
206 # internal API209 # internal API
207 def _append_app(self, app):210 def _append_app(self, app):
208 """ append a application to the current store, keep 211 """ append a application to the current store, keep
@@ -249,6 +252,12 @@
249252
250 # external API253 # external API
251 def clear(self):254 def clear(self):
255 """Clear the store and disconnect all callbacks to allow it to be
256 deleted."""
257 self.backend.disconnect_by_func(self._on_transaction_finished)
258 self.backend.disconnect_by_func(self._on_transaction_started)
259 self.backend.disconnect_by_func(self._on_transaction_progress_changed)
260 self.icons.disconnect_by_func(self._clear_app_icon_cache)
252 self.apps = []261 self.apps = []
253 self.app_index_map.clear()262 self.app_index_map.clear()
254 self.pkgname_index_map.clear()263 self.pkgname_index_map.clear()
@@ -289,7 +298,6 @@
289298
290 # Re-claim the memory used by the new appstore299 # Re-claim the memory used by the new appstore
291 appstore.clear()300 appstore.clear()
292 del appstore
293301
294 def _refresh_contents_data(self):302 def _refresh_contents_data(self):
295 # Quantitative data on stored packages. This generates the information.303 # Quantitative data on stored packages. This generates the information.
296304
=== modified file 'softwarecenter/view/channelpane.py'
--- softwarecenter/view/channelpane.py 2010-05-21 05:31:19 +0000
+++ softwarecenter/view/channelpane.py 2010-05-28 16:37:28 +0000
@@ -100,7 +100,6 @@
100 old_model = self.app_view.get_model()100 old_model = self.app_view.get_model()
101 if old_model is not None:101 if old_model is not None:
102 old_model.active = False102 old_model.active = False
103 self.app_view.set_model(None)
104 gobject.idle_add(self._make_new_model, query, self.refresh_seq_nr)103 gobject.idle_add(self._make_new_model, query, self.refresh_seq_nr)
105 return False104 return False
106105