[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56961] trunk/blender/source/blender/ editors/space_clip/tracking_ops.c: De-duplicate zero resolution check in marker add operators.

Sergey Sharybin sergey.vfx at gmail.com
Wed May 22 08:28:59 CEST 2013


Revision: 56961
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56961
Author:   nazgul
Date:     2013-05-22 06:28:59 +0000 (Wed, 22 May 2013)
Log Message:
-----------
De-duplicate zero resolution check in marker add operators.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c

Modified: trunk/blender/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2013-05-22 06:22:28 UTC (rev 56960)
+++ trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2013-05-22 06:28:59 UTC (rev 56961)
@@ -80,7 +80,7 @@
 
 /********************** add marker operator *********************/
 
-static void add_marker(const bContext *C, float x, float y)
+static bool add_marker(const bContext *C, float x, float y)
 {
 	SpaceClip *sc = CTX_wm_space_clip(C);
 	MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -92,11 +92,17 @@
 
 	ED_space_clip_get_size(sc, &width, &height);
 
+	if (width == 0 || height == 0) {
+		return false;
+	}
+
 	track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
 
 	BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, 0);
 
 	clip->tracking.act_track = track;
+
+	return true;
 }
 
 static int add_marker_exec(bContext *C, wmOperator *op)
@@ -104,17 +110,13 @@
 	SpaceClip *sc = CTX_wm_space_clip(C);
 	MovieClip *clip = ED_space_clip_get_clip(sc);
 	float pos[2];
-	int width, height;
 
-	ED_space_clip_get_size(sc, &width, &height);
+	RNA_float_get_array(op->ptr, "location", pos);
 
-	if (!width || !height)
+	if (!add_marker(C, pos[0], pos[1])) {
 		return OPERATOR_CANCELLED;
+	}
 
-	RNA_float_get_array(op->ptr, "location", pos);
-
-	add_marker(C, pos[0], pos[1]);
-
 	/* reset offset from locked position, so frame jumping wouldn't be so confusing */
 	sc->xlockof = 0;
 	sc->ylockof = 0;
@@ -167,19 +169,15 @@
 	MovieClip *clip = ED_space_clip_get_clip(sc);
 	ARegion *ar = CTX_wm_region(C);
 	float pos[2];
-	int width, height;
 
-	ED_space_clip_get_size(sc, &width, &height);
-
-	if (!width || !height)
-		return OPERATOR_CANCELLED;
-
 	ED_clip_point_stable_pos(sc, ar,
 	                         BLI_rcti_size_x(&ar->winrct) / 2.0f,
 	                         BLI_rcti_size_y(&ar->winrct) / 2.0f,
 	                         &pos[0], &pos[1]);
 
-	add_marker(C, pos[0], pos[1]);
+	if (!add_marker(C, pos[0], pos[1])) {
+		return OPERATOR_CANCELLED;
+	}
 
 	/* reset offset from locked position, so frame jumping wouldn't be so confusing */
 	sc->xlockof = 0;




More information about the Bf-blender-cvs mailing list