[gcompris/gcomprixogoo] Fixed a crash that happened while loading an animation where item
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Fixed a crash that happened while loading an animation where item
- Date: Sun, 22 Nov 2009 19:32:03 +0000 (UTC)
commit 6eb33077f10d2d9f3cc8e7bf21b913405f371cec
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Sun Nov 22 20:30:45 2009 +0100
Fixed a crash that happened while loading an animation where item
had been deleted and the z order was set.
src/anim-activity/AnimItem.py | 1 +
src/anim-activity/anim.py | 24 +++++++++++++++++-------
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/anim-activity/AnimItem.py b/src/anim-activity/AnimItem.py
index 3436403..6e48ec0 100644
--- a/src/anim-activity/AnimItem.py
+++ b/src/anim-activity/AnimItem.py
@@ -297,6 +297,7 @@ class AnimItem:
if not self.visible:
AnimItem.anim.deleteItem(self)
self.show(False)
+ AnimItem.anim.doc.delete_from_zorder(self.id)
def raise_(self):
parent = self.item.get_parent()
diff --git a/src/anim-activity/anim.py b/src/anim-activity/anim.py
index bc2f39e..dc9a010 100644
--- a/src/anim-activity/anim.py
+++ b/src/anim-activity/anim.py
@@ -710,6 +710,15 @@ class Document:
item.display_at_time(time)
self.restore_zorder()
+ # If an item is removed, we must remove it from all
+ # the timelines in which we saved a z_order
+ def delete_from_zorder(self, item_id):
+ for z_order in self.zorder.values():
+ try:
+ z_order.remove(item_id)
+ except ValueError:
+ pass
+
def save_zorder(self):
z_order = []
for i in range(self.rootitem.get_n_children()):
@@ -725,12 +734,13 @@ class Document:
z_order = self.zorder[self.timeline.get_time()]
for i in range(self.rootitem.get_n_children()):
item = self.rootitem.get_child(i)
- item_id = item.get_data("id")
- try:
- z_index = z_order.index(item_id)
- self.rootitem.move_child(i, z_index);
- except ValueError:
- pass
+ if item:
+ item_id = item.get_data("id")
+ try:
+ z_index = z_order.index(item_id)
+ self.rootitem.move_child(i, z_index);
+ except ValueError:
+ pass
def anim_to_file(self, filename):
@@ -779,8 +789,8 @@ class Document:
self.zorder = pickle.load(file)
# Restore is complete
- self.refresh(self.timeline.get_time())
self.timeline.set_time(0)
+ self.refresh(0)
else:
print "ERROR: Unrecognized file format, file", filename, ' has description : ', desc
file.close()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]