Fix T50062: Mask - Clicking in ActivePoint Parent makes Blender crash.
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 2 Dec 2016 09:45:03 +0000 (10:45 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 2 Dec 2016 09:47:18 +0000 (10:47 +0100)
Mask primitive adding code was not initializing correctly id_type of
points' parents.

source/blender/blenloader/intern/versioning_270.c
source/blender/editors/mask/mask_add.c

index 25d78b73d5950caafbd7b1457ea55fb3b6564153..88c583b827e19bf1dba05ef4cedc00a4b32ba42d 100644 (file)
@@ -46,6 +46,7 @@
 #include "DNA_screen_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
+#include "DNA_mask_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_particle_types.h"
@@ -60,6 +61,7 @@
 #include "BKE_colortools.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_mask.h"
 #include "BKE_modifier.h"
 #include "BKE_node.h"
 #include "BKE_scene.h"
@@ -1473,4 +1475,21 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        br->fill_threshold /= sqrt_3;
                }
        }
+
+       /* To be added to next subversion bump! */
+       {
+               /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
+               for (Mask *mask = main->mask.first; mask; mask = mask->id.next) {
+                       for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
+                               for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
+                                       int i = 0;
+                                       for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) {
+                                               if (mspoint->parent.id_type == 0) {
+                                                       BKE_mask_parent_init(&mspoint->parent);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
 }
index e3e8f35e7d82606f1f865cf8d66ae610bd2dff10..f01af22cec9a6d5cb57c8660756823853d6e19de 100644 (file)
@@ -779,6 +779,7 @@ static int create_primitive_from_points(bContext *C, wmOperator *op, const float
 
        for (i = 0; i < num_points; i++) {
                MaskSplinePoint *new_point = &new_spline->points[i];
+               BKE_mask_parent_init(&new_point->parent);
 
                copy_v2_v2(new_point->bezt.vec[1], points[i]);
                mul_v2_fl(new_point->bezt.vec[1], scale);