Modified:
trunk/SDK/PyFR/Appliance.py
trunk/SDK/PyFR/DynamicMenuController.py
trunk/SDK/PyFR/FileBrowser.py
trunk/SDK/PyFR/MenuController.py
trunk/SDK/PyFR/OptionDialog.py
trunk/SDK/PyFR/Utilities.py
Log:
Plugging memory leaks; call autorelease or release where necessary
Modified: trunk/SDK/PyFR/Appliance.py
==============================================================================
--- trunk/SDK/PyFR/Appliance.py (original)
+++ trunk/SDK/PyFR/Appliance.py Sun Oct 26 22:20:58 2008
@@ -12,12 +12,14 @@
@classmethod
def initialize(cls):
name = NSString.alloc().initWithString_(
u"com.apple.frontrow.appliance.frontpython" )
+ #name.autorelease()
BRFeatureManager.sharedInstance().enableFeatureNamed_( name )
@classmethod
def className(cls):
clsName = NSString.alloc().initWithString_( cls.__name__ )
+ #clsName.autorelease()
backtrace = BRBacktracingException.backtrace()
range = backtrace.rangeOfString_( "_loadApplianceInfoAtPath:" )
@@ -29,7 +31,8 @@
if range.location != Foundation.NSNotFound:
clsName =
NSString.alloc().initWithString_( "RUIMoviesAppliance" )
-
+ #clsName.autorelease()
+
return clsName
def applianceController(self):
Modified: trunk/SDK/PyFR/DynamicMenuController.py
==============================================================================
--- trunk/SDK/PyFR/DynamicMenuController.py (original)
+++ trunk/SDK/PyFR/DynamicMenuController.py Sun Oct 26 22:20:58 2008
@@ -101,8 +101,9 @@
class DynamicMenuController(BRMediaMenuController,ControllerUtilities):
def dealloc():
- self.log("Deallocing MenuController %s" % self.title)
- return BRMediaMenuController.dealloc(self)
+ self.log("Deallocing DynamicMenuController %s" %
self.title.encode("ascii","replace")))
+ self.ds.release()
+ return super(BRMediaMenuController,self).dealloc()
def initWithMenu_(self, menu):
BRMenuController.init(self)
Modified: trunk/SDK/PyFR/FileBrowser.py
==============================================================================
--- trunk/SDK/PyFR/FileBrowser.py (original)
+++ trunk/SDK/PyFR/FileBrowser.py Sun Oct 26 22:20:58 2008
@@ -37,6 +37,7 @@
if menuItem.folder:
menuController =
FileBrowserController.alloc().initWithDirectory_( selectedFile )
+ menuController.autorelease()
self.stack().pushController_(menuController)
else:
self.fileSelected_( selectedFile )
Modified: trunk/SDK/PyFR/MenuController.py
==============================================================================
--- trunk/SDK/PyFR/MenuController.py (original)
+++ trunk/SDK/PyFR/MenuController.py Sun Oct 26 22:20:58 2008
@@ -6,6 +6,12 @@
from Utilities import ControllerUtilities
+import Foundation
+def log(s):
+ #Foundation.NSLog( "%s: %s" % ("PyeTV", str(s) ) )
+ pass
+
+
# in individual menu item with text, a function to be called when
activated, and an optionional argument to be passed to the function
class MenuItem(ControllerUtilities):
def __init__(self,title,func,arg=None,metadata_func=None,
smalltext=False):
@@ -20,7 +26,7 @@
self.func(controller, self.arg)
def GetMetadata(self, controller):
- #self.log("In GetMetadata for menu item %s" % self.title)
+ self.log("In GetMetadata for menu item %s" %
self.title.encode("ascii","replace"))
if self.metadata_func is not None:
return self.metadata_func(controller, self.arg)
else:
@@ -40,7 +46,7 @@
return ""
def GetMetadata(self, controller):
- #self.log("In GetMetadata for menu %s" % self.page_title)
+ self.log("In GetMetadata for menu %s" %
self.page_title.encode("ascii","replace"))
if self.metadata_func is not None:
return self.metadata_func(controller, self.page_title)
else:
@@ -56,6 +62,17 @@
def init(self):
return NSObject.init(self)
+ def dealloc(self):
+ log("MenuDataSource dealloc called")
+ #clean up locally-allocated resources
+ for item in self.menu.items:
+ try:
+ log("releasing layer %s for menu item %s" %
(item.layer, item))
+ item.layer.release()
+ except:
+ pass
+ #return super(NSObject,self).dealloc()
+
def initWithController_Menu_(self, ctrlr, menu):
self.ctrlr = ctrlr
self.menu = menu
@@ -96,6 +113,7 @@
return
if IsMenu(self.menu.items[row]):
con =
MenuController.alloc().initWithMenu_(self.menu.items[row])
+ con.autorelease()
self.ctrlr.stack().pushController_(con)
else:
self.menu.items[row].Activate(self.ctrlr)
@@ -105,7 +123,9 @@
def previewControlForItem_(self, row):
if row >= len(self.menu.items):
return None
- return self.menu.items[row].GetMetadata(self.ctrlr)
+ log("calling GetMetadata")
+ ret=self.menu.items[row].GetMetadata(self.ctrlr)
+ return ret
def RemoveItem(self,item):
self.items.remove(item)
@@ -122,9 +142,10 @@
class MenuController(BRMediaMenuController,ControllerUtilities):
- def dealloc():
- self.log("Deallocing MenuController %s" % self.title)
- return BRMediaMenuController.dealloc(self)
+ def dealloc(self):
+ self.log("Dealloc: MenuController %s (%s)" %
(self.title.encode("ascii","replace"),repr(self)))
+ self.ds.release()
+ return super(BRMediaMenuController,self).dealloc()
def initWithMenu_(self, menu):
BRMenuController.init(self)
Modified: trunk/SDK/PyFR/OptionDialog.py
==============================================================================
--- trunk/SDK/PyFR/OptionDialog.py (original)
+++ trunk/SDK/PyFR/OptionDialog.py Sun Oct 26 22:20:58 2008
@@ -58,11 +58,13 @@
def testOptionDialogTest(controller,arg):
dlg=OptionDialog.alloc().initWithTitle_Items_Handler_UserData_("Test
options",["Select a1","Select b","Select
c"],testOptionDialogHandler,["a","b","c"])
+ #dlg.autorelease()
return controller.stack().pushController_(dlg)
def testFromMain():
menuItems = [ OptionItem( "select %d" % i, i+50 ) for i in range(0,3) ]
- return OptionDialog.alloc().initWithTitle_Items_Handler_( "Test
options",
+ ret=OptionDialog.alloc().initWithTitle_Items_Handler_( "Test options",
menuItems )
-
+ #ret.autorelease()
+ return ret
Modified: trunk/SDK/PyFR/Utilities.py
==============================================================================
--- trunk/SDK/PyFR/Utilities.py (original)
+++ trunk/SDK/PyFR/Utilities.py Sun Oct 26 22:20:58 2008
@@ -101,7 +101,7 @@
# I probably shouldn't use a sleep here, as thats not good GUI
# practice. But it works. Not like its going to be around long
in
# here.
- time.sleep(0.5)
+ time.sleep(0.25)
# Well, we already hid, so we may move this.
self.AboutToHideFR()