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):
"""
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:
:rtype:
@ -172,6 +173,8 @@ class GenerateTool(EditorTool):
column = []
self.generatorTypes = [pluginClass(self) for pluginClass in _pluginClasses]
self.currentGenerator = None
if len(self.generatorTypes):
self.currentGenerator = self.generatorTypes[0]
self.generatorTypeInput = QtGui.QComboBox()
@ -296,6 +299,8 @@ class GenerateTool(EditorTool):
def updateNodePreview(self):
bounds = self.previewBounds
if self.currentGenerator is None:
return
if bounds is not None and bounds.volume > 0:
node = self.currentGenerator.getPreviewNode(bounds)
@ -315,6 +320,8 @@ class GenerateTool(EditorTool):
if bounds is None:
self.clearSchematic()
return
if self.currentGenerator is None:
return
try:
schematic = self.currentGenerator.generate(bounds, self.editorSession.worldEditor.blocktypes)
@ -361,6 +368,9 @@ class GenerateTool(EditorTool):
self.loader = None
def generateClicked(self):
if self.currentGenerator is None:
return
if self.schematicBounds is None:
log.info("schematicBounds is None, not generating")
return