[Bf-blender-cvs] [b956d031348] asset-greasepencil: GPencil: Fix wrong array size and cleanup Hash code
Antonio Vazquez
noreply at git.blender.org
Fri Jul 16 17:07:20 CEST 2021
Commit: b956d0313489dad04ea2f3fe8d4fceaa12a26b54
Author: Antonio Vazquez
Date: Fri Jul 16 17:07:11 2021 +0200
Branches: asset-greasepencil
https://developer.blender.org/rBb956d0313489dad04ea2f3fe8d4fceaa12a26b54
GPencil: Fix wrong array size and cleanup Hash code
===================================================================
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 5d13f98b3e7..801d946d367 100644
--- a/source/blender/editors/gpencil/gpencil_asset.c
+++ b/source/blender/editors/gpencil/gpencil_asset.c
@@ -105,7 +105,7 @@ typedef struct tGPDasset {
* | |
* 6----5----4
*/
- float manipulator[7][2];
+ float manipulator[8][2];
/** Hash of new created layers. */
struct GHash *asset_layers;
@@ -355,10 +355,9 @@ static bool gpencil_asset_import_set_init_values(bContext *C,
tgpa->mode = GP_ASSET_TRANSFORM_LOC;
- /* Create Hash tables. */
- tgpa->asset_layers = BLI_ghash_ptr_new(__func__);
- tgpa->asset_frames = BLI_ghash_ptr_new(__func__);
- tgpa->asset_strokes = BLI_ghash_ptr_new(__func__);
+ tgpa->asset_layers = NULL;
+ tgpa->asset_frames = NULL;
+ tgpa->asset_strokes = NULL;
return true;
}
@@ -489,6 +488,9 @@ static void gpencil_asset_add_strokes(tGPDasset *tgpa)
gpl_target = BKE_gpencil_layer_addnew(gpd_target, gpl_asset->info, false, false);
BLI_assert(gpl_target != NULL);
+ if (tgpa->asset_layers == NULL) {
+ tgpa->asset_layers = BLI_ghash_ptr_new(__func__);
+ }
/* Add to the hash to remove if operator is canceled. */
BLI_ghash_insert(tgpa->asset_layers, gpl_target, gpl_target);
}
@@ -502,6 +504,9 @@ static void gpencil_asset_add_strokes(tGPDasset *tgpa)
gpl_target, gpf_asset->framenum, GP_GETFRAME_ADD_NEW);
BLI_assert(gpf_target != NULL);
+ if (tgpa->asset_frames == NULL) {
+ tgpa->asset_frames = BLI_ghash_ptr_new(__func__);
+ }
/* Add to the hash to remove if operator is canceled. */
if (!BLI_ghash_haskey(tgpa->asset_frames, gpf_target)) {
/* Add the hash key with a reference to the layer. */
@@ -509,6 +514,10 @@ static void gpencil_asset_add_strokes(tGPDasset *tgpa)
}
}
/* Loop all strokes and duplicate. */
+ if (tgpa->asset_strokes == NULL) {
+ tgpa->asset_strokes = BLI_ghash_ptr_new(__func__);
+ }
+
LISTBASE_FOREACH (bGPDstroke *, gps_asset, &gpf_asset->strokes) {
bGPDstroke *gps_target = BKE_gpencil_stroke_duplicate(gps_asset, true, true);
BLI_addtail(&gpf_target->strokes, gps_target);
More information about the Bf-blender-cvs
mailing list