Bug#871782: Patch for fife to plug memory leak

2017-08-21 Thread Markus Koschany
Control: tags -1 pending
Control: block -1 by 872774

I have prepared a stretch-pu. The fix is pending.

Markus



signature.asc
Description: OpenPGP digital signature


Bug#871782: Patch for fife to plug memory leak

2017-08-11 Thread Petter Reinholdtsen
Here is a tested quilt patch to be stored in
debian/patches/1000-icon-mem-leak.patch.

I could not verify that all leaks are plugged, as the program is
still increasing in size while playing, and I do not know if this
is normal or not.  But the code in question make sense and is from
upstream, so it should at least reduce the amount of memory used. :)

I tested with the patch in place, and the game is working as it should.
I was not able to trigger the slowdown, but do not know if I played
long enough. :)
-- 
Happy hacking
Petter Reinholdtsen
Description: pychan: Remove Icon from manager on source load failure

When creating an `Icon` with an invalid file path, the `Icon` object
first calls its parent's `__init__()` and then trys to load the image
source.  Loading the image might end up in e.g. `fife.NotFound`, but the
parent's `__init__()` already added the new `Icon` instance to the
manager. So while the code creating the `Icon` will never see an
instance of it and can never call `hide()` to remove it, the manager
still thinks that there's an instance available.

This commit changes to code to remove the `Icon` from the manager for
any occuring exception and then re-raise the exception.

Origin: https://github.com/fifengine/fifengine/commit/2efebb3a0940e2570d2e7abeb54957dcb6f110ea
Author: MasterofJOKers 
Bug-Debian: https://bugs.debian.org/871782

diff --git a/engine/python/fife/extensions/pychan/widgets/icon.py b/engine/python/fife/extensions/pychan/widgets/icon.py
index 9d5daf3b..b94a6a58 100644
--- a/engine/python/fife/extensions/pychan/widgets/icon.py
+++ b/engine/python/fife/extensions/pychan/widgets/icon.py
@@ -26,6 +26,7 @@ from fife import fifechan
 from fife.extensions.pychan.attrs import Attr, BoolAttr
 from fife.extensions.pychan.properties import ImageProperty
 
+from common import get_manager
 from widget import Widget
 
 
@@ -88,7 +89,11 @@ class Icon(Widget):
 
 		if scale is not None: self.scale = scale
 
-		self.image = image
+		try:
+			self.image = image
+		except Exception:
+			get_manager().removeWidget(self)
+			raise
 		
 		#if the size parameter is specified set it (again) to override
 		#the icons size.