[ease] Fixed undo runtime errors when slide has been switched, and possibly a memory leak.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Fixed undo runtime errors when slide has been switched, and possibly a memory leak.
- Date: Thu, 20 May 2010 05:51:10 +0000 (UTC)
commit ab1d9f53793039fdb8cabd45984cf32551f01aaa
Author: Nate Stedman <natesm gmail com>
Date: Thu May 20 01:49:39 2010 -0400
Fixed undo runtime errors when slide has been switched, and possibly a memory leak.
Unfortunately, this has killed undo performance. A better solution is needed (Elements point to all current Actors representing them?)
src/libease/Actor.vala | 15 ++++++++
src/libease/EditorEmbed.vala | 6 ++--
src/libease/EditorWindow.vala | 1 +
src/libease/SlideActor.vala | 73 ++++++++++++++++++++++++++++-------------
src/libease/UndoActions.vala | 10 ++---
vapi/clutter-1.0.vapi | 4 +-
6 files changed, 75 insertions(+), 34 deletions(-)
---
diff --git a/src/libease/Actor.vala b/src/libease/Actor.vala
index 769a9f3..7cb8646 100644
--- a/src/libease/Actor.vala
+++ b/src/libease/Actor.vala
@@ -54,6 +54,21 @@ public class Ease.Actor : Clutter.Group
}
/**
+ * Rereads the Actor's { link Element} to position it properly.
+ *
+ * Used after reverting an action.
+ */
+ public void reposition()
+ {
+ x = element.x;
+ y = element.y;
+ width = element.width;
+ height = element.height;
+ contents.width = width;
+ contents.height = height;
+ }
+
+ /**
* Move this Actor and update its { link Element}
*
* Used in the editor and tied to Clutter MotionEvents.
diff --git a/src/libease/EditorEmbed.vala b/src/libease/EditorEmbed.vala
index ddf4360..8dedac6 100644
--- a/src/libease/EditorEmbed.vala
+++ b/src/libease/EditorEmbed.vala
@@ -42,7 +42,7 @@ public class Ease.EditorEmbed : ScrollableEmbed
private Handle[] handles;
// the current slide's actor
- private SlideActor slide_actor;
+ public SlideActor slide_actor;
// the currently selected Actor
private Actor selected;
@@ -339,7 +339,7 @@ public class Ease.EditorEmbed : ScrollableEmbed
is_dragging = false;
Clutter.ungrab_pointer();
sender.motion_event.disconnect(actor_motion);
- win.add_undo_action(new MoveUndoAction(selected.element, selected,
+ win.add_undo_action(new MoveUndoAction(selected.element,
orig_x, orig_y,
orig_w, orig_h));
}
@@ -425,7 +425,7 @@ public class Ease.EditorEmbed : ScrollableEmbed
is_dragging = false;
sender.motion_event.disconnect(handle_motion);
- win.add_undo_action(new MoveUndoAction(selected.element, selected,
+ win.add_undo_action(new MoveUndoAction(selected.element,
orig_x, orig_y,
orig_w, orig_h));
}
diff --git a/src/libease/EditorWindow.vala b/src/libease/EditorWindow.vala
index 3f4388c..af83ad4 100644
--- a/src/libease/EditorWindow.vala
+++ b/src/libease/EditorWindow.vala
@@ -166,6 +166,7 @@ public class Ease.EditorWindow : Gtk.Window
main_toolbar.undo.clicked.connect(() => {
undo.undo();
update_undo();
+ embed.slide_actor.relayout();
embed.reposition_group();
});
diff --git a/src/libease/SlideActor.vala b/src/libease/SlideActor.vala
index 11cf220..2a7c40b 100644
--- a/src/libease/SlideActor.vala
+++ b/src/libease/SlideActor.vala
@@ -73,29 +73,7 @@ public class Ease.SlideActor : Clutter.Group
}
// set the background
- if (slide.background_image != null)
- {
- try
- {
- background = new Clutter.Texture.from_file(document.path +
- slide.background_image);
- background.width = document.width;
- background.height = document.height;
- }
- catch (GLib.Error e)
- {
- stdout.printf("Error loading background: %s", e.message);
- }
- }
- else // the background is a solid color
- {
- background = new Clutter.Rectangle();
- ((Clutter.Rectangle)background).set_color(slide.background_color);
- background.width = document.width;
- background.height = document.height;
- }
-
- add_actor(background);
+ set_background();
contents = new Clutter.Group();
@@ -118,6 +96,55 @@ public class Ease.SlideActor : Clutter.Group
add_actor(contents);
}
+
+ public void relayout()
+ {
+ set_background();
+
+ for (unowned List<Clutter.Actor>* itr = contents.get_children();
+ itr != null;
+ itr = itr->next)
+ {
+ ((Actor)(itr->data)).reposition();
+ }
+ }
+
+ /**
+ * Builds the background actor for this SlideActor.
+ */
+ private void set_background()
+ {
+ if (background != null)
+ {
+ if (background.get_parent() == this)
+ {
+ remove_actor(background);
+ }
+ }
+
+ if (slide.background_image != null)
+ {
+ try
+ {
+ background = new Clutter.Texture.from_file(slide.parent.path +
+ slide.background_image);
+ }
+ catch (GLib.Error e)
+ {
+ stdout.printf("Error loading background: %s", e.message);
+ }
+ }
+ else // the background is a solid color
+ {
+ background = new Clutter.Rectangle();
+ ((Clutter.Rectangle)background).set_color(slide.background_color);
+ }
+ background.width = slide.parent.width;
+ background.height = slide.parent.height;
+
+ add_actor(background);
+ lower_child(background, null);
+ }
// stack the actor, removing children from container if needed
public void stack(Clutter.Actor container)
diff --git a/src/libease/UndoActions.vala b/src/libease/UndoActions.vala
index cc86321..0688f36 100644
--- a/src/libease/UndoActions.vala
+++ b/src/libease/UndoActions.vala
@@ -38,7 +38,6 @@ public abstract class Ease.UndoAction : Object
public class Ease.MoveUndoAction : UndoAction
{
private Element element;
- private weak Actor actor;
private float x_pos;
private float y_pos;
private float width;
@@ -48,15 +47,14 @@ public class Ease.MoveUndoAction : UndoAction
* Creates a new MoveUndoAction.
*
* @param element The { link Element} this applies to.
- * @param x The origin X position of the { link Actor}.
- * @param y The origin Y position of the { link Actor}.
- * @param w The origin width of the { link Actor}
- * @param h The origin height position of the { link Actor}
+ * @param x The original X position of the { link Element}.
+ * @param y The original Y position of the { link Element}.
+ * @param w The original width of the { link Element}
+ * @param h The original height position of the { link Element}
*/
public MoveUndoAction(Element e, float x, float y, float w, float h)
{
element = e;
- actor = a;
x_pos = x;
y_pos = y;
width = w;
diff --git a/vapi/clutter-1.0.vapi b/vapi/clutter-1.0.vapi
index 660ae9b..7b66d3c 100644
--- a/vapi/clutter-1.0.vapi
+++ b/vapi/clutter-1.0.vapi
@@ -927,8 +927,8 @@ namespace Clutter {
public abstract Clutter.ChildMeta get_child_meta (Clutter.Actor actor);
public unowned GLib.List get_children ();
public abstract void lower (Clutter.Actor actor, Clutter.Actor sibling);
- public void lower_child (Clutter.Actor actor, Clutter.Actor sibling);
- public abstract void raise (Clutter.Actor actor, Clutter.Actor sibling);
+ public void lower_child (Clutter.Actor actor, Clutter.Actor? sibling);
+ public abstract void raise (Clutter.Actor actor, Clutter.Actor? sibling);
public void raise_child (Clutter.Actor actor, Clutter.Actor sibling);
public abstract void remove (Clutter.Actor actor);
public void remove_actor (Clutter.Actor actor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]