changeset 1180:bfd7d466a022

Fix yeiling error message when select a scene. - It is caused by the buggy fixing of changeset #7d700e5f82ba for an eariler error of frameline.get_frame_block() - Fix frameline.get_frame_block() with correct logic and fix early code relied on the buggy fix.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 31 Dec 2010 11:31:18 +0800
parents b65df4f0d30a
children f14dbcf19e2b
files pyink/MBScene.py pyink/frameline.py
diffstat 2 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/MBScene.py	Fri Dec 31 11:10:14 2010 +0800
+++ b/pyink/MBScene.py	Fri Dec 31 11:31:18 2010 +0800
@@ -626,12 +626,14 @@
 		    tween_obj_tween_type = \
 			self._tween_obj_tween_types[tween_type_idx]
 		    
-		    next_idx, next_stop_idx, next_tween_type = \
-			layer.get_frame_block(stop_idx + 1)
-		    if next_idx == -1:
+		    try:
+			next_idx, next_stop_idx, next_tween_type = \
+			    layer.get_frame_block(stop_idx + 1)
+		    except:
 			next_scene_group = scene_group
 		    else:
 			next_scene_group = layer.get_frame_data(next_idx)
+			pass
 		    
 		    nframes = stop_idx - start_idx + 1
 		    percent = float(idx - start_idx) / nframes
--- a/pyink/frameline.py	Fri Dec 31 11:10:14 2010 +0800
+++ b/pyink/frameline.py	Fri Dec 31 11:31:18 2010 +0800
@@ -708,7 +708,7 @@
 		return 
 	    pass
 	pass
-        pass
+    
     def rm_keyframe(self, idx):
 	key_pos = self._find_keyframe(idx)
         key = self._keys[key_pos]
@@ -765,6 +765,10 @@
 	    pass
 	pass
 
+    ## \bref Return range of blocks of conesequence frames (tweens).
+    #
+    # Return range and type of tweens and key frames that is not start or stop
+    # of a tween.
     def get_frame_blocks(self):
 	blocks = []
 	for pos, key in enumerate(self._keys):
@@ -779,18 +783,27 @@
 	    pass
 	return blocks
 
+    ## \brief Return the range of a block of consequence frames (tween).
+    # 
+    # - If the index frame is in a tween, it returns the range of the tween.
+    #
+    # - If the indexed frame is a key frame with no right_tween, returns the
+    #   range that start and stop are both equivalent to idx.
+    #
+    # - Otherwise, raise an exception.
+    #
+    # \param idx is the index number of a frame.
+    # \return A tuple of (start, stop, tween_type)
+    #
     def get_frame_block(self, idx):
 	pos = self._find_keyframe_floor(idx)
 	if pos != -1:
 	    key = self._keys[pos]
-	    print key.right_tween, key.left_tween
-	    if key.idx == idx:
-		return key.idx, key.idx, 0
-	    elif key.right_tween:
+	    if key.right_tween:
 		next_key = self._keys[pos + 1]
 		return key.idx, next_key.idx, key.right_tween_type
-	    else:
-		return -1,-1,-1
+	    elif key.idx == idx:
+		return key.idx, key.idx, 0
 	    pass
 	raise ValueError, \
 	    'the frame specified by idx is not in any tween or a key frame'