[clutter] align: Check that source is not contained inside the actor
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] align: Check that source is not contained inside the actor
- Date: Fri, 2 Sep 2011 15:16:32 +0000 (UTC)
commit e6dbdb444d61dc2172d98566589ece846cbe03ce
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Sep 2 13:56:25 2011 +0100
align: Check that source is not contained inside the actor
AlignConstraint won't work if the source is a child or a grandchild of
the ClutterActorMeta:actor to which it has been attached to: the
allocation flows from the parent to its children, not the other way
around; in order to avoid weirdness, we better document and check
that when we set the actor and when we set the source.
clutter/clutter-align-constraint.c | 39 ++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter-align-constraint.c b/clutter/clutter-align-constraint.c
index 8ec342c..c7f415d 100644
--- a/clutter/clutter-align-constraint.c
+++ b/clutter/clutter-align-constraint.c
@@ -40,6 +40,8 @@
#include "clutter-align-constraint.h"
+#include "clutter-actor-meta-private.h"
+#include "clutter-actor-private.h"
#include "clutter-constraint.h"
#include "clutter-debug.h"
#include "clutter-enum-types.h"
@@ -107,6 +109,19 @@ clutter_align_constraint_set_actor (ClutterActorMeta *meta,
ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (meta);
ClutterActorMetaClass *parent;
+ if (new_actor != NULL &&
+ align->source != NULL &&
+ clutter_actor_contains (new_actor, align->source))
+ {
+ g_warning (G_STRLOC ": The source actor '%s' is contained "
+ "by the actor '%s' associated to the constraint "
+ "'%s'",
+ _clutter_actor_get_debug_name (align->source),
+ _clutter_actor_get_debug_name (new_actor),
+ _clutter_actor_meta_get_debug_name (meta));
+ return;
+ }
+
/* store the pointer to the actor, for later use */
align->actor = new_actor;
@@ -243,7 +258,10 @@ clutter_align_constraint_class_init (ClutterAlignConstraintClass *klass)
/**
* ClutterAlignConstraint:source:
*
- * The #ClutterActor used as the source for the alignment
+ * The #ClutterActor used as the source for the alignment.
+ *
+ * The #ClutterActor must not be a child or a grandchild of the actor
+ * using the constraint.
*
* Since: 1.4
*/
@@ -346,7 +364,8 @@ void
clutter_align_constraint_set_source (ClutterAlignConstraint *align,
ClutterActor *source)
{
- ClutterActor *old_source;
+ ClutterActor *old_source, *actor;
+ ClutterActorMeta *meta;
g_return_if_fail (CLUTTER_IS_ALIGN_CONSTRAINT (align));
g_return_if_fail (source == NULL || CLUTTER_IS_ACTOR (source));
@@ -354,6 +373,22 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align,
if (align->source == source)
return;
+ meta = CLUTTER_ACTOR_META (align);
+ actor = clutter_actor_meta_get_actor (meta);
+ if (actor != NULL && source != NULL)
+ {
+ if (clutter_actor_contains (actor, source))
+ {
+ g_warning (G_STRLOC ": The source actor '%s' is contained "
+ "by the actor '%s' associated to the constraint "
+ "'%s'",
+ _clutter_actor_get_debug_name (source),
+ _clutter_actor_get_debug_name (actor),
+ _clutter_actor_meta_get_debug_name (meta));
+ return;
+ }
+ }
+
old_source = align->source;
if (old_source != NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]