raise an exception properly when a window fails to open

This commit is contained in:
David Rose 2005-02-17 18:01:42 +00:00
parent b905967e2d
commit 9dae916780

View File

@ -102,6 +102,7 @@ class ShowBase(DirectObject.DirectObject):
self.aspectRatio = ConfigVariableDouble('aspect-ratio', 0) self.aspectRatio = ConfigVariableDouble('aspect-ratio', 0)
self.windowType = self.config.GetString('window-type', 'onscreen') self.windowType = self.config.GetString('window-type', 'onscreen')
self.requireWindow = self.config.GetBool('require-window', 1)
# base.win is the main, or only window; base.winList is a list of # base.win is the main, or only window; base.winList is a list of
# *all* windows. Similarly with base.camList. # *all* windows. Similarly with base.camList.
@ -483,20 +484,11 @@ class ShowBase(DirectObject.DirectObject):
self.closeWindow(self.win) self.closeWindow(self.win)
if self.win == None: if self.win == None:
# This doesn't really need to be an error condition, but I self.notify.warning("Unable to open '%s' window." % (self.windowType))
# figure any app that includes ShowBase really wants to if self.requireWindow:
# have a window open. # Unless require-window is set to false, it is an
# error not to open a window.
# For toontown, it is possible that window open failed raise StandardError, 'Could not open window.'
# because of a graphics card issue. In that case, take
# user to the appropriate page.
self.notify.error("Unable to open '%s' window." % (self.windowType))
try:
launcher.setPandaErrorCode(14)
sys.exit(1)
except:
pass
return (self.win != None) return (self.win != None)
@ -860,12 +852,12 @@ class ShowBase(DirectObject.DirectObject):
""" """
if self.buttonThrowers != None: if self.buttonThrowers != None:
for bt in self.buttonThrowers: for bt in self.buttonThrowers:
mw = bt.getParent() mw = bt.getParent()
mk = mw.getParent() mk = mw.getParent()
bt.removeNode() bt.removeNode()
mw.removeNode() mw.removeNode()
mk.removeNode() mk.removeNode()
# For each mouse/keyboard device, we create # For each mouse/keyboard device, we create
# - MouseAndKeyboard # - MouseAndKeyboard