Fix T38670: Mask transform without a movieclip crashes
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 17 Feb 2014 06:58:50 +0000 (12:58 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 17 Feb 2014 06:58:50 +0000 (12:58 +0600)
Disable transform and mask display when there's no active clip.

It's not a matter of returning fallback dimensions if there's no
slip, it's also matter of making it so stabilization and distortion
routines are aware of clip == NULL which is really crappy.

Also almost all the operators are disabled in clip editor without
active clip already anyway.

Also tweaked header UI a bit to not display mask stuff when there's
no active clip,

release/scripts/startup/bl_ui/space_clip.py
source/blender/editors/space_clip/space_clip.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c

index 42ad9daafa53ac38b4b3fcad25ff82a83e058500..7ee46934a1cb7fabf31641eda3665a330da987a2 100644 (file)
@@ -124,17 +124,18 @@ class CLIP_HT_header(Header):
 
         layout.prop(sc, "mode", text="")
 
-        row = layout.row()
-        row.template_ID(sc, "mask", new="mask.new")
+        if clip:
+            row = layout.row()
+            row.template_ID(sc, "mask", new="mask.new")
 
-        layout.prop(sc, "pivot_point", text="", icon_only=True)
+            layout.prop(sc, "pivot_point", text="", icon_only=True)
 
-        row = layout.row(align=True)
-        row.prop(toolsettings, "use_proportional_edit_mask",
-                 text="", icon_only=True)
-        if toolsettings.use_proportional_edit_mask:
-            row.prop(toolsettings, "proportional_edit_falloff",
-                     text="", icon_only=True)
+            row = layout.row(align=True)
+            row.prop(toolsettings, "use_proportional_edit_mask",
+                    text="", icon_only=True)
+            if toolsettings.use_proportional_edit_mask:
+                row.prop(toolsettings, "proportional_edit_falloff",
+                         text="", icon_only=True)
 
     def draw(self, context):
         layout = self.layout
index 886b38d39a1ab75532ab517d9f91c0e3950b9f72..624ced55bb9bf4533d040a46a9ac22d33b2e404b 100644 (file)
@@ -1186,7 +1186,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
 
        if (sc->mode == SC_MODE_MASKEDIT) {
                Mask *mask = CTX_data_edit_mask(C);
-               if (mask) {
+               if (mask && clip) {
                        ScrArea *sa = CTX_wm_area(C);
                        int mask_width, mask_height;
                        ED_mask_get_size(sa, &mask_width, &mask_height);
index 4269e18734eb788e969e004f4ced7c9b804490bc..e5c8877f076c5b959aa4a412479d46c134585bfe 100644 (file)
@@ -414,26 +414,34 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
                SpaceClip *sc = t->sa->spacedata.first;
 
                if (t->options & CTX_MASK) {
-                       /* not working quite right, TODO (see above too) */
-                       float aspx, aspy;
-                       float v[2];
+                       MovieClip *clip = ED_space_clip_get_clip(sc);
 
-                       ED_space_clip_get_aspect(sc, &aspx, &aspy);
+                       if (clip) {
+                               /* not working quite right, TODO (see above too) */
+                               float aspx, aspy;
+                               float v[2];
 
-                       copy_v2_v2(v, vec);
+                               ED_space_clip_get_aspect(sc, &aspx, &aspy);
 
-                       v[0] = v[0] / aspx;
-                       v[1] = v[1] / aspy;
+                               copy_v2_v2(v, vec);
 
-                       BKE_mask_coord_to_movieclip(sc->clip, &sc->user, v, v);
+                               v[0] = v[0] / aspx;
+                               v[1] = v[1] / aspy;
 
-                       v[0] = v[0] / aspx;
-                       v[1] = v[1] / aspy;
+                               BKE_mask_coord_to_movieclip(sc->clip, &sc->user, v, v);
 
-                       ED_clip_point_stable_pos__reverse(sc, t->ar, v, v);
+                               v[0] = v[0] / aspx;
+                               v[1] = v[1] / aspy;
 
-                       adr[0] = v[0];
-                       adr[1] = v[1];
+                               ED_clip_point_stable_pos__reverse(sc, t->ar, v, v);
+
+                               adr[0] = v[0];
+                               adr[1] = v[1];
+                       }
+                       else {
+                               adr[0] = 0;
+                               adr[1] = 0;
+                       }
                }
                else if (t->options & CTX_MOVIECLIP) {
                        float v[2], aspx, aspy;
index 95fe8beb76a52115b58276585d4f5022c61c9a43..31123827c4c0fe20aa0cb18aff39eaec882eec44 100644 (file)
@@ -6763,6 +6763,14 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
        if (!mask)
                return;
 
+       if (t->spacetype == SPACE_CLIP) {
+               SpaceClip *sc = t->sa->spacedata.first;
+               MovieClip *clip = ED_space_clip_get_clip(sc);
+               if (!clip) {
+                       return;
+               }
+       }
+
        /* count */
        for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
                MaskSpline *spline;