fix: fix fatal error when exporting virtools file

- fix fatal error that user only can export virtools file into existing file, rather than any new file.
This commit is contained in:
2025-09-23 21:45:56 +08:00
parent f920cdcaf5
commit e4a4eae88e
2 changed files with 12 additions and 3 deletions

View File

@ -44,9 +44,18 @@ class BBP_OT_export_virtools(bpy.types.Operator, UTIL_file_browser.ExportVirtool
self.report({'ERROR'}, 'You must specify at least one encoding for file saving (e.g. cp1252, gbk)!') self.report({'ERROR'}, 'You must specify at least one encoding for file saving (e.g. cp1252, gbk)!')
return {'CANCELLED'} return {'CANCELLED'}
# check file name # check file name, but has slightly difference with importer.
# when exporting, file can be inexisting in file system, so we can't check it directly.
filename = self.general_get_filename() filename = self.general_get_filename()
if not os.path.isfile(filename): bad_filename: bool = False
# for filename, at first, it should not be empty surely.
if len(filename) == 0:
bad_filename = True
# then, if it is existing, it should be a file, otherwise everything is okey.
if os.path.exists(filename) and (not os.path.isfile(filename)):
bad_filename = True
# now, show message and exit if we have bad file name
if bad_filename:
self.report({'ERROR'}, 'No file was selected!') self.report({'ERROR'}, 'No file was selected!')
return {'CANCELLED'} return {'CANCELLED'}

View File

@ -6,7 +6,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension # Example of manifest file for a Blender extension
# Change the values according to your extension # Change the values according to your extension
id = "bbp_ng" id = "bbp_ng"
version = "4.3.0" version = "4.3.1"
name = "Ballance Blender Plugin" name = "Ballance Blender Plugin"
tagline = "The specialized add-on served for creating game map of Ballance" tagline = "The specialized add-on served for creating game map of Ballance"
maintainer = "yyc12345 <yyc12321@outlook.com>" maintainer = "yyc12345 <yyc12321@outlook.com>"