[Bf-blender-cvs] [bb44e5c73a8] asset-lite-greasepencil: Error message if the asset is empty

Antonio Vazquez noreply at git.blender.org
Fri Jun 24 17:12:57 CEST 2022


Commit: bb44e5c73a89e034b58d8204b669f64466a485ab
Author: Antonio Vazquez
Date:   Fri Jun 24 17:12:50 2022 +0200
Branches: asset-lite-greasepencil
https://developer.blender.org/rBbb44e5c73a89e034b58d8204b669f64466a485ab

Error message if the asset is empty

===================================================================

M	source/blender/editors/gpencil/gpencil_asset.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_asset.c b/source/blender/editors/gpencil/gpencil_asset.c
index e0a3f5face9..edda5be259d 100644
--- a/source/blender/editors/gpencil/gpencil_asset.c
+++ b/source/blender/editors/gpencil/gpencil_asset.c
@@ -143,6 +143,7 @@ static void apply_layer_settings(bGPDlayer *gpl)
 /* Helper: Create an asset for data block.
  * return: False if there are features non supported. */
 static bool gpencil_asset_create(const bContext *C,
+                                 const wmOperator *op,
                                  const bGPdata *gpd_src,
                                  const bGPDlayer *gpl_filter,
                                  const eGP_AssetModes mode,
@@ -275,6 +276,20 @@ static bool gpencil_asset_create(const bContext *C,
     is_animation |= (BLI_listbase_count(&gpl->frames) > 1);
   }
 
+  /* Check if something to do. */
+  bool do_export = false;
+  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+    if (BLI_listbase_count(&gpl->frames) > 0) {
+      do_export = true;
+      break;
+    }
+  }
+  /* Nothing to export. */
+  if (!do_export) {
+    BKE_report(op->reports, RPT_ERROR, "No strokes were found to create the asset.");
+    return false;
+  }
+
   /* Set origin to bounding box of strokes. */
   if (reset_origin) {
     float gpcenter[3];
@@ -360,12 +375,12 @@ static int gpencil_asset_create_exec(const bContext *C, const wmOperator *op)
   if (mode == GP_ASSET_MODE_ALL_LAYERS_SPLIT) {
     LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd_src->layers) {
       non_supported_feature |= gpencil_asset_create(
-          C, gpd_src, gpl, mode, reset_origin, flatten_layers);
+          C, op, gpd_src, gpl, mode, reset_origin, flatten_layers);
     }
   }
   else {
     non_supported_feature = gpencil_asset_create(
-        C, gpd_src, NULL, mode, reset_origin, flatten_layers);
+        C, op, gpd_src, NULL, mode, reset_origin, flatten_layers);
   }
 
   /* Warnings for non supported features in the created asset. */



More information about the Bf-blender-cvs mailing list