Code changes to avoid the indexError: NSRangeException error when returning from an update check.

git-svn-id: http://munki.googlecode.com/svn/trunk@943 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2010-12-01 01:58:31 +00:00
parent 46bbc2d596
commit d6f9c9286b
3 changed files with 66 additions and 38 deletions
@@ -32,15 +32,23 @@ class MSUOptionalInstallsViewController(NSViewController):
array_controller = IBOutlet()
window_controller = IBOutlet()
AddRemoveBtn = IBOutlet()
_EMPTYOPTIONALLIST = NSArray.arrayWithArray_([{"installed": NO,
"managed": NO,
"original_managed": NO,
"name": "",
"version": "",
"description": "",
"size": "",
"enabled": NO,
"status": "",
"original_status": ""}])
_optionallist = NSArray.arrayWithArray_([{"installed": NO, "managed": NO, "original_managed": NO,
"name": "", "version": "",
"description": "", "size": "", "enabled": NO,
"status": "", "original_status": ""}])
_optionallist = []
def optionallist(self):
#NSLog(u"MSUOptionalInstallsViewController.optionallist")
return self._optionallist
return self._optionallist or self._EMPTYOPTIONALLIST
objc.accessor(optionallist) # PyObjC KVO hack
def setOptionallist_(self, newlist):
@@ -100,22 +108,24 @@ class MSUOptionalInstallsViewController(NSViewController):
self.window_controller.theTabView.selectPreviousTabViewItem_(sender)
NSApp.delegate().addOrRemoveOptionalSoftware()
def updateWebKitView_(self, description):
if "</html>" in description or "</HTML>" in description:
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
else:
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
buffer(description),
u"text/plain", u"utf-8", None)
def updateDescriptionView(self):
#NSLog(u"MSUOptionalInstallsViewController.updateDescriptionView")
if len(self.array_controller.selectedObjects()):
row = self.array_controller.selectedObjects()[0]
description = row.get("description","")
if "</html>" in description or "</HTML>" in description:
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
else:
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
buffer(description),
u"text/plain", u"utf-8", None)
description = row.get("description", u"")
self.updateRowStatus()
else:
self.descriptionView.mainFrame().loadHTMLString_baseURL_(u"", None)
description = u""
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateWebKitView_, description, NO)
def tableViewSelectionDidChange_(self, sender):
#NSLog(u"MSUOptionalInstallsViewController.tableViewSelectionDidChange_")
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
#self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
self.updateDescriptionView()