diff pyink/MBScene.py @ 1161:a7faab54e8f8

Fix broken of running animation - Running animation is stop automatically after a certain time. - It is 300ms according MBScene._updateUI(). - It is caused by notification of changing DOM tree. The notification handlers would call MBScene.updateUI() to update framelines and buttons. - MBScene.updateUI() would call MBScene.show() after 300ms, MBScene.show() calls MBScene.parseScene() in turn. - MBScene.parseScene() would remove duplicate group that is using by code of running animation, MBScene.doRunNext(). It make running animation stop. - fixed by setting MBScene.lockui when a running animation is started or stoped.
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 28 Dec 2010 13:35:34 +0800
parents 1a699dc00fa3
children c23593881507
line wrap: on
line diff
--- a/pyink/MBScene.py	Tue Dec 28 13:35:34 2010 +0800
+++ b/pyink/MBScene.py	Tue Dec 28 13:35:34 2010 +0800
@@ -86,7 +86,7 @@
         if self.type == 'DOMSubtreeModified':
 	    self.func(node)
     def notifyAttributeChanged(self,node, name, old_value, new_value):
-        print 'attr',node,name,old_value,new_value
+        # print 'attr',node,name,old_value,new_value
         if self.type == 'DOMAttrModified':
 	    self.func(node,name)
 
@@ -336,6 +336,8 @@
 		        try:
 			    label = scene.getAttribute('inkscape:label')
 			    if label == 'dup':
+				# XXX: This would stop animation.
+				# This function is called by updateUI()
 			        node.removeChild(scene)
 			except:
 			    pass
@@ -873,16 +875,22 @@
 	"""
 	if self.btnRun.get_label() == "Run":
 	    self.btnRun.set_label("Stop")
+	    self.lockui = True
             self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
 	else:
 	    self.btnRun.set_label("Run")
 	    glib.source_remove(self.last_update)
+	    self.lockui = False
+	    pass
 
     def doRunNext(self):
 	if self.current >= self.maxframe:
 	    self.current = 0
-	print self.current,self.maxframe
-	self.setCurrentScene(self.current+1)
+	try:
+	    self.setCurrentScene(self.current+1)
+	except:
+	    traceback.print_exc()
+	    raise
         self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)