Skip to content

Commit e97aad7

Browse files
committed
fix: throw warning if image data is invalid
1 parent fbcf139 commit e97aad7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ntp_operator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,13 +1048,19 @@ def _save_image(self, img: bpy.types.Image) -> None:
10481048
if img is None:
10491049
return
10501050

1051+
img_str = img_to_py_str(img)
1052+
1053+
if not img.has_data:
1054+
self.report({'WARNING'}, f"{img_str} has no data")
1055+
return
1056+
10511057
# create image dir if one doesn't exist
10521058
img_dir = os.path.join(self._addon_dir, IMAGE_DIR_NAME)
10531059
if not os.path.exists(img_dir):
10541060
os.mkdir(img_dir)
10551061

10561062
# save the image
1057-
img_str = img_to_py_str(img)
1063+
10581064
img_path = f"{img_dir}/{img_str}"
10591065
if not os.path.exists(img_path):
10601066
img.save_render(img_path)

0 commit comments

Comments
 (0)