Fix T38670: Mask transform without a movieclip crashes

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,
This commit is contained in:
Sergey Sharybin 2014-02-17 12:58:50 +06:00
parent 9c79fd1193
commit 1776cb9244
Notes: blender-bot 2023-02-14 11:10:59 +01:00
Referenced by issue #38670, Mask transform without a movieclip crashes.
4 changed files with 40 additions and 23 deletions

View 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

View 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);

View 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;

View 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;