GenerateTool handles an empty generatorTypes and a None currentGenerator.

Hopefully this should never happen.
This commit is contained in:
David Vierra 2015-05-13 21:46:00 -10:00
parent aaefc96f19
commit b22bbcb225

View File

@ -102,6 +102,7 @@ class GeneratePlugin(QtCore.QObject):
def updatePreview(self): def updatePreview(self):
""" """
Trigger the GenerateTool to call generate() on this GeneratePlugin again. This function should be Trigger the GenerateTool to call generate() on this GeneratePlugin again. This function should be
called by the plugin whenever one of the options provided by the options widget is changed.
:return: :return:
:rtype: :rtype:
@ -172,7 +173,9 @@ class GenerateTool(EditorTool):
column = [] column = []
self.generatorTypes = [pluginClass(self) for pluginClass in _pluginClasses] self.generatorTypes = [pluginClass(self) for pluginClass in _pluginClasses]
self.currentGenerator = self.generatorTypes[0] self.currentGenerator = None
if len(self.generatorTypes):
self.currentGenerator = self.generatorTypes[0]
self.generatorTypeInput = QtGui.QComboBox() self.generatorTypeInput = QtGui.QComboBox()
for gt in self.generatorTypes: for gt in self.generatorTypes:
@ -296,6 +299,8 @@ class GenerateTool(EditorTool):
def updateNodePreview(self): def updateNodePreview(self):
bounds = self.previewBounds bounds = self.previewBounds
if self.currentGenerator is None:
return
if bounds is not None and bounds.volume > 0: if bounds is not None and bounds.volume > 0:
node = self.currentGenerator.getPreviewNode(bounds) node = self.currentGenerator.getPreviewNode(bounds)
@ -315,6 +320,8 @@ class GenerateTool(EditorTool):
if bounds is None: if bounds is None:
self.clearSchematic() self.clearSchematic()
return return
if self.currentGenerator is None:
return
try: try:
schematic = self.currentGenerator.generate(bounds, self.editorSession.worldEditor.blocktypes) schematic = self.currentGenerator.generate(bounds, self.editorSession.worldEditor.blocktypes)
@ -361,6 +368,9 @@ class GenerateTool(EditorTool):
self.loader = None self.loader = None
def generateClicked(self): def generateClicked(self):
if self.currentGenerator is None:
return
if self.schematicBounds is None: if self.schematicBounds is None:
log.info("schematicBounds is None, not generating") log.info("schematicBounds is None, not generating")
return return