Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2021-10-03 19:57:28 +0300
committerVilem Duha <vilem.duha@gmail.com>2021-10-03 19:57:28 +0300
commit2965c7afc0d5e951b9bee16a1dcf182f2aec0a44 (patch)
treed475603b542ec2a774148b9925b6935827bb8fc2 /blenderkit
parent0e4e0814061aba83c58ba8eb8cba2651248a44db (diff)
BlenderKit fix bg blender crash due to new file preview code
A new preview code from 6th september crashes Blender when saving files in background mode. This circumvents the bug by now.
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/append_link.py5
-rw-r--r--blenderkit/autothumb.py6
-rw-r--r--blenderkit/autothumb_material_bg.py4
-rw-r--r--blenderkit/autothumb_model_bg.py3
-rw-r--r--blenderkit/resolutions.py3
-rw-r--r--blenderkit/upload.py3
-rw-r--r--blenderkit/upload_bg.py3
7 files changed, 24 insertions, 3 deletions
diff --git a/blenderkit/append_link.py b/blenderkit/append_link.py
index 21cf2ec2..481504fb 100644
--- a/blenderkit/append_link.py
+++ b/blenderkit/append_link.py
@@ -318,11 +318,11 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar
# check for object that should be hidden
if ob.users_collection[0].name == collection_name:
collection = ob.users_collection[0]
+ collection['is_blenderkit_asset'] = True
+
else:
to_hidden_collection.append(ob)
-
-
if kwargs.get('rotation'):
main_object.rotation_euler = kwargs['rotation']
@@ -344,7 +344,6 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar
bpy.ops.object.select_all(action='DESELECT')
utils.selection_set(sel)
#let collection also store info that it was created by BlenderKit, for purging reasons
- collection['is_blenderkit_asset'] = True
return main_object, return_obs
diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py
index c19e4507..f5e0cd34 100644
--- a/blenderkit/autothumb.py
+++ b/blenderkit/autothumb.py
@@ -283,7 +283,10 @@ class GenerateThumbnailOperator(bpy.types.Operator):
bkit.thumbnail = rel_thumb_path + '.jpg'
bkit.thumbnail_generating_state = 'Saving .blend file'
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
# save a copy of actual scene but don't interfere with the users models
+
bpy.ops.wm.save_as_mainfile(filepath=filepath, compress=False, copy=True)
# get all included objects
obs = utils.get_hierarchy(asset)
@@ -471,6 +474,9 @@ class GenerateMaterialThumbnailOperator(bpy.types.Operator):
asset = bpy.context.active_object.active_material
tempdir = tempfile.mkdtemp()
filepath = os.path.join(tempdir, "material_thumbnailer_cycles.blend")
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
# save a copy of actual scene but don't interfere with the users models
bpy.ops.wm.save_as_mainfile(filepath=filepath, compress=False, copy=True)
diff --git a/blenderkit/autothumb_material_bg.py b/blenderkit/autothumb_material_bg.py
index 50e8aa4b..37d7c783 100644
--- a/blenderkit/autothumb_material_bg.py
+++ b/blenderkit/autothumb_material_bg.py
@@ -50,6 +50,10 @@ if __name__ == "__main__":
if data.get('do_download'):
#need to save the file, so that asset doesn't get downloaded into addon directory
temp_blend_path = os.path.join(data['tempdir'], 'temp.blend')
+
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
bpy.ops.wm.save_as_mainfile(filepath=temp_blend_path)
asset_data = data['asset_data']
diff --git a/blenderkit/autothumb_model_bg.py b/blenderkit/autothumb_model_bg.py
index df9872fa..2ce76830 100644
--- a/blenderkit/autothumb_model_bg.py
+++ b/blenderkit/autothumb_model_bg.py
@@ -84,6 +84,9 @@ if __name__ == "__main__":
if data.get('do_download'):
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
#need to save the file, so that asset doesn't get downloaded into addon directory
temp_blend_path = os.path.join(data['tempdir'], 'temp.blend')
bpy.ops.wm.save_as_mainfile(filepath = temp_blend_path)
diff --git a/blenderkit/resolutions.py b/blenderkit/resolutions.py
index 645a306d..7a3f3671 100644
--- a/blenderkit/resolutions.py
+++ b/blenderkit/resolutions.py
@@ -386,6 +386,9 @@ def generate_lower_resolutions(data):
i.pack()
# save
print(fpath)
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
# save the file
bpy.ops.wm.save_as_mainfile(filepath=fpath, compress=True, copy=True)
# compare file sizes
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index bf207293..c724dde5 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -1101,6 +1101,9 @@ def start_upload(self, context, asset_type, reupload, upload_set):
export_data['temp_dir'] = tempfile.mkdtemp()
export_data['source_filepath'] = os.path.join(export_data['temp_dir'], "export_blenderkit" + ext)
if asset_type != 'HDR':
+ # if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
bpy.ops.wm.save_as_mainfile(filepath=export_data['source_filepath'], compress=False, copy=True)
export_data['binary_path'] = bpy.app.binary_path
diff --git a/blenderkit/upload_bg.py b/blenderkit/upload_bg.py
index 1b91d51b..1f29d9ff 100644
--- a/blenderkit/upload_bg.py
+++ b/blenderkit/upload_bg.py
@@ -174,6 +174,9 @@ if __name__ == "__main__":
fpath = os.path.join(export_data['temp_dir'], upload_data['assetBaseId'] + '.blend')
+ #if this isn't here, blender crashes.
+ bpy.context.preferences.filepaths.file_preview_type = 'NONE'
+
bpy.ops.wm.save_as_mainfile(filepath=fpath, compress=True, copy=False)
os.remove(export_data['source_filepath'])