actor: Add ActorIter.is_valid()

It can be useful to check whether a ClutterActorIter is currently valid,
i.e. if the iterator has been initialized *and* if the actor to which it
refers to hasn't been updated.

We can also use the is_valid() method in the conformance test suite to
check that initialization has been successful, and that changing the
children list through the ClutterActorIter API leaves the iterator in a
valid state.
This commit is contained in:
Emmanuele Bassi
2012-06-27 12:57:36 +01:00
parent 1ca4937f1e
commit 1da42dd8a0
4 changed files with 44 additions and 4 deletions

View File

@ -17193,6 +17193,33 @@ clutter_actor_iter_init (ClutterActorIter *iter,
ri->age = root->priv->age;
}
/**
* clutter_actor_iter_is_valid:
* @iter: a #ClutterActorIter
*
* Checks whether a #ClutterActorIter is still valid.
*
* An iterator is considered valid if it has been initialized, and
* if the #ClutterActor that it refers to hasn't been modified after
* the initialization.
*
* Return value: %TRUE if the iterator is valid, and %FALSE otherwise
*
* Since: 1.12
*/
gboolean
clutter_actor_iter_is_valid (const ClutterActorIter *iter)
{
RealActorIter *ri = (RealActorIter *) iter;
g_return_val_if_fail (iter != NULL, FALSE);
if (ri->root == NULL)
return FALSE;
return ri->root->priv->age == ri->age;
}
/**
* clutter_actor_iter_next:
* @iter: a #ClutterActorIter