[Bf-blender-cvs] [6f1ad5f5e77] master: Fix wrong key type for GSet in Grease Pencil same material selection

Lukas Stockner noreply at git.blender.org
Tue Apr 12 00:03:30 CEST 2022


Commit: 6f1ad5f5e77ca5b5c257db97798e9a2087c9defd
Author: Lukas Stockner
Date:   Mon Apr 11 23:56:11 2022 +0200
Branches: master
https://developer.blender.org/rB6f1ad5f5e77ca5b5c257db97798e9a2087c9defd

Fix wrong key type for GSet in Grease Pencil same material selection

The type of the key was changed from string to integer in 66da2f537ae8, but
the GSet was still being created for string keys.

As long as the integers stay small enough, this even kind of works on
little-endian systems, but of course it should use an integer hash instead.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index d962dcdfa10..c4fd34212c3 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -826,7 +826,7 @@ static bool gpencil_select_same_material(bContext *C)
   bGPdata *gpd = ED_gpencil_data_get_active(C);
   const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
   /* First, build set containing all the colors of selected strokes */
-  GSet *selected_colors = BLI_gset_str_new("GP Selected Colors");
+  GSet *selected_colors = BLI_gset_int_new("GP Selected Colors");
 
   bool changed = false;
 
@@ -835,7 +835,7 @@ static bool gpencil_select_same_material(bContext *C)
       /* add instead of insert here, otherwise the uniqueness check gets skipped,
        * and we get many duplicate entries...
        */
-      BLI_gset_add(selected_colors, &gps->mat_nr);
+      BLI_gset_add(selected_colors, POINTER_FROM_INT(gps->mat_nr));
     }
   }
   CTX_DATA_END;
@@ -843,7 +843,8 @@ static bool gpencil_select_same_material(bContext *C)
   /* Second, select any visible stroke that uses these colors */
   if (is_curve_edit) {
     CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
-      if (gps->editcurve != NULL && BLI_gset_haskey(selected_colors, &gps->mat_nr)) {
+      if (gps->editcurve != NULL &&
+          BLI_gset_haskey(selected_colors, POINTER_FROM_INT(gps->mat_nr))) {
         bGPDcurve *gpc = gps->editcurve;
         for (int i = 0; i < gpc->tot_curve_points; i++) {
           bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -861,7 +862,7 @@ static bool gpencil_select_same_material(bContext *C)
   }
   else {
     CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
-      if (BLI_gset_haskey(selected_colors, &gps->mat_nr)) {
+      if (BLI_gset_haskey(selected_colors, POINTER_FROM_INT(gps->mat_nr))) {
         /* select this stroke */
         bGPDspoint *pt;
         int i;



More information about the Bf-blender-cvs mailing list