Remove checks for valid frame from poll function in clip editor space
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Jun 2012 16:36:19 +0000 (16:36 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Jun 2012 16:36:19 +0000 (16:36 +0000)
This results in some buttons not disabled when there's no currently displaying frame,
but this saves lots of cache lookups and threading loks for every frame update.

source/blender/editors/include/ED_clip.h
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/tracking_ops.c

index 6b1028525a7ec1638889b0d0df6db5b5e2dd2e5b..1d42954a416778f699f6d0402cc05f589a0570fc 100644 (file)
@@ -47,8 +47,6 @@ int ED_space_clip_poll(struct bContext *C);
 int ED_space_clip_view_clip_poll(struct bContext *C);
 
 int ED_space_clip_tracking_poll(struct bContext *C);
-int ED_space_clip_tracking_size_poll(struct bContext *C);
-int ED_space_clip_tracking_frame_poll(struct bContext *C);
 int ED_space_clip_maskedit_poll(struct bContext *C);
 int ED_space_clip_maskedit_mask_poll(bContext *C);
 
index ab100b46f70b3aae8bc8a5e3d58902683db85fb2..bcda1d59555c8fd8680c6748f8f5d137a29d9ff0 100644 (file)
@@ -96,39 +96,6 @@ int ED_space_clip_tracking_poll(bContext *C)
        return FALSE;
 }
 
-int ED_space_clip_tracking_size_poll(bContext *C)
-{
-       if (ED_space_clip_tracking_poll(C)) {
-               MovieClip *clip = CTX_data_edit_movieclip(C);
-
-               if (clip) {
-                       SpaceClip *sc = CTX_wm_space_clip(C);
-                       int width, height;
-
-                       BKE_movieclip_get_size(clip, &sc->user, &width, &height);
-
-                       return width > 0 && height > 0;
-               }
-       }
-
-       return FALSE;
-}
-
-int ED_space_clip_tracking_frame_poll(bContext *C)
-{
-       if (ED_space_clip_tracking_poll(C)) {
-               MovieClip *clip = CTX_data_edit_movieclip(C);
-
-               if (clip) {
-                       SpaceClip *sc = CTX_wm_space_clip(C);
-
-                       return BKE_movieclip_has_frame(clip, &sc->user);
-               }
-       }
-
-       return FALSE;
-}
-
 int ED_space_clip_maskedit_poll(bContext *C)
 {
        SpaceClip *sc = CTX_wm_space_clip(C);
index 7073fdb35428f0dd02c35f6b156d743d4ea61384..fdd4dfc57d082680dde84867a1a6965f4c777eff 100644 (file)
@@ -107,6 +107,7 @@ static int add_marker_exec(bContext *C, wmOperator *op)
        int width, height;
 
        ED_space_clip_size(sc, &width, &height);
+
        if (!width || !height)
                return OPERATOR_CANCELLED;
 
@@ -144,7 +145,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke = add_marker_invoke;
        ot->exec = add_marker_exec;
-       ot->poll = ED_space_clip_tracking_size_poll;
+       ot->poll = ED_space_clip_tracking_poll;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -638,7 +639,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot)
        ot->idname = "CLIP_OT_slide_marker";
 
        /* api callbacks */
-       ot->poll = ED_space_clip_tracking_size_poll;
+       ot->poll = ED_space_clip_tracking_poll;
        ot->invoke = slide_marker_invoke;
        ot->modal = slide_marker_modal;
 
@@ -1308,7 +1309,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = select_groped_exec;
-       ot->poll = ED_space_clip_tracking_size_poll;
+       ot->poll = ED_space_clip_tracking_poll;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1693,7 +1694,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
        /* api callbacks */
        ot->exec = track_markers_exec;
        ot->invoke = track_markers_invoke;
-       ot->poll = ED_space_clip_tracking_frame_poll;
+       ot->poll = ED_space_clip_tracking_poll;
        ot->modal = track_markers_modal;
 
        /* flags */
@@ -2134,19 +2135,17 @@ static Object *get_orientation_object(bContext *C)
 
 static int set_orientation_poll(bContext *C)
 {
-       if (ED_space_clip_tracking_size_poll(C)) {
-               Scene *scene = CTX_data_scene(C);
-               SpaceClip *sc = CTX_wm_space_clip(C);
-               MovieClip *clip = ED_space_clip(sc);
-               MovieTracking *tracking = &clip->tracking;
-               MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+       Scene *scene = CTX_data_scene(C);
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       MovieClip *clip = ED_space_clip(sc);
+       MovieTracking *tracking = &clip->tracking;
+       MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
 
-               if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
-                       return TRUE;
-               }
-               else {
-                       return OBACT != NULL;
-               }
+       if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
+               return TRUE;
+       }
+       else {
+               return OBACT != NULL;
        }
 
        return FALSE;
@@ -2744,16 +2743,12 @@ void CLIP_OT_set_scale(wmOperatorType *ot)
 
 static int set_solution_scale_poll(bContext *C)
 {
-       if (ED_space_clip_tracking_size_poll(C)) {
-               SpaceClip *sc = CTX_wm_space_clip(C);
-               MovieClip *clip = ED_space_clip(sc);
-               MovieTracking *tracking = &clip->tracking;
-               MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
-
-               return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0;
-       }
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       MovieClip *clip = ED_space_clip(sc);
+       MovieTracking *tracking = &clip->tracking;
+       MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
 
-       return 0;
+       return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0;
 }
 
 static int set_solution_scale_exec(bContext *C, wmOperator *op)
@@ -2963,6 +2958,11 @@ static int detect_features_exec(bContext *C, wmOperator *op)
        int framenr = ED_space_clip_clip_framenr(sc);
        bGPDlayer *layer = NULL;
 
+       if (!ibuf) {
+               BKE_report(op->reports, RPT_ERROR, "Feature detection requires valid clip frame");
+               return OPERATOR_CANCELLED;
+       }
+
        if (placement != 0) {
                layer = detect_get_layer(clip);
                place_outside_layer = placement == 2;
@@ -3003,7 +3003,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = detect_features_exec;
-       ot->poll = ED_space_clip_tracking_frame_poll;
+       ot->poll = ED_space_clip_tracking_poll;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3156,7 +3156,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = join_tracks_exec;
-       ot->poll = ED_space_clip_tracking_size_poll;
+       ot->poll = ED_space_clip_tracking_poll;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;