[clutter] bind: Check that the source is not contained inside the actor
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] bind: Check that the source is not contained inside the actor
- Date: Fri, 2 Sep 2011 15:16:46 +0000 (UTC)
commit 66607dec4de1676b970053defe33db9634ba6923
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Sep 2 13:58:34 2011 +0100
bind: Check that the source is not contained inside the actor
Like commit d0439cfb586ca14282c89035119a4acbc0295df7 for
AlignConstraint, let's check that the BindConstraint source is not
a child or a grandchild of the actor attached to the Constraint.
clutter/clutter-bind-constraint.c | 39 +++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter-bind-constraint.c b/clutter/clutter-bind-constraint.c
index 472562e..a234721 100644
--- a/clutter/clutter-bind-constraint.c
+++ b/clutter/clutter-bind-constraint.c
@@ -88,6 +88,8 @@
#include "clutter-bind-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"
@@ -208,6 +210,19 @@ clutter_bind_constraint_set_actor (ClutterActorMeta *meta,
ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (meta);
ClutterActorMetaClass *parent;
+ if (new_actor != NULL &&
+ bind->source != NULL &&
+ clutter_actor_contains (new_actor, bind->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 (bind->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 */
bind->actor = new_actor;
@@ -307,7 +322,10 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass)
/**
* ClutterBindConstraint:source:
*
- * The #ClutterActor used as the source for the binding
+ * The #ClutterActor used as the source for the binding.
+ *
+ * The #ClutterActor must not be contained inside the actor associated
+ * to the constraint.
*
* Since: 1.4
*/
@@ -403,7 +421,8 @@ void
clutter_bind_constraint_set_source (ClutterBindConstraint *constraint,
ClutterActor *source)
{
- ClutterActor *old_source;
+ ClutterActor *old_source, *actor;
+ ClutterActorMeta *meta;
g_return_if_fail (CLUTTER_IS_BIND_CONSTRAINT (constraint));
g_return_if_fail (source == NULL || CLUTTER_IS_ACTOR (source));
@@ -411,6 +430,22 @@ clutter_bind_constraint_set_source (ClutterBindConstraint *constraint,
if (constraint->source == source)
return;
+ meta = CLUTTER_ACTOR_META (constraint);
+ actor = clutter_actor_meta_get_actor (meta);
+ if (source != NULL && actor != 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 = constraint->source;
if (old_source != NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]