Skip to content

Commit

Permalink
fix 'struct rna of ExportGodot removed' error if upexpected error occ…
Browse files Browse the repository at this point in the history
…ured while exporting
  • Loading branch information
U-TTE\celpec committed Feb 10, 2021
1 parent be76c4e commit 146a81f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 5 additions & 2 deletions io_scene_godot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def check_extension(self):

def execute(self, context):
"""Begin the export"""
exporter_log_handler = export_godot.ExporterLogHandler(self)
try:
if not self.filepath:
raise Exception("filepath not set")
Expand All @@ -218,12 +219,14 @@ def execute(self, context):
"filter_glob",
"xna_validate",
))

logging.getLogger().addHandler(exporter_log_handler)
return export_godot.save(self, context, **keywords)
except ValidationError as error:
self.report({'ERROR'}, str(error))
return {'CANCELLED'}

finally:
if exporter_log_handler:
logging.getLogger().removeHandler(exporter_log_handler)

def menu_func(self, context):
"""Add to the menu"""
Expand Down
4 changes: 0 additions & 4 deletions io_scene_godot/export_godot.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ def __exit__(self, *exc):

def save(operator, context, filepath="", **kwargs):
"""Begin the export"""
exporter_log_handler = ExporterLogHandler(operator)
logging.getLogger().addHandler(exporter_log_handler)

object_types = kwargs["object_types"]
# GEOMETRY isn't an object type so replace it with all valid geometry based
Expand All @@ -326,6 +324,4 @@ def save(operator, context, filepath="", **kwargs):
with GodotExporter(filepath, kwargs, operator) as exp:
exp.export()

logging.getLogger().removeHandler(exporter_log_handler)

return {"FINISHED"}

0 comments on commit 146a81f

Please sign in to comment.