2007-11-23 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-actor.c (clutter_actor_destroy): Bail out
	if clutter_actor_destroy() was called on the stage: the stage
	is not for the user to destroy.

	* clutter/x11/clutter-backend-x11.c:
	* clutter/eglnative/clutter-backend-egl.c:
	* clutter/sdl/clutter-backend-sdl.c:
	* clutter/osx/clutter-backend-osx.c: Unset the top-level private
	flag on the stage when disposing it, so the backends can safely
	call clutter_actor_destroy().

	* clutter/clutter-private.h: Tweak the private flags accessors,
	to avoid the typecheck.
This commit is contained in:
Emmanuele Bassi 2007-11-23 11:20:14 +00:00
parent 8039922802
commit e57b42ae52
7 changed files with 49 additions and 7 deletions

View File

@ -1,3 +1,19 @@
2007-11-23 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.c (clutter_actor_destroy): Bail out
if clutter_actor_destroy() was called on the stage: the stage
is not for the user to destroy.
* clutter/x11/clutter-backend-x11.c:
* clutter/eglnative/clutter-backend-egl.c:
* clutter/sdl/clutter-backend-sdl.c:
* clutter/osx/clutter-backend-osx.c: Unset the top-level private
flag on the stage when disposing it, so the backends can safely
call clutter_actor_destroy().
* clutter/clutter-private.h: Tweak the private flags accessors,
to avoid the typecheck.
2007-11-22 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-label.c (clutter_label_new_full): Set the

View File

@ -1619,15 +1619,30 @@ clutter_actor_init (ClutterActor *self)
* container, the actor will be removed.
*
* When you destroy a container its children will be destroyed as well.
*
* Note: you cannot destroy the #ClutterStage returned by
* clutter_stage_get_default().
*/
void
clutter_actor_destroy (ClutterActor *self)
{
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
if (self->priv->parent_actor)
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)
{
ClutterActor *parent = self->priv->parent_actor;
g_warning ("Calling clutter_actor_destroy() on an actor of type `%s' "
"is not possible. This is usually an application bug.",
g_type_name (G_OBJECT_TYPE (self)));
return;
}
priv = self->priv;
if (priv->parent_actor)
{
ClutterActor *parent = priv->parent_actor;
if (CLUTTER_IS_CONTAINER (parent))
{
@ -1635,7 +1650,7 @@ clutter_actor_destroy (ClutterActor *self)
clutter_container_remove_actor (CLUTTER_CONTAINER (parent), self);
}
else
self->priv->parent_actor = NULL;
priv->parent_actor = NULL;
}
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION))

View File

@ -98,9 +98,9 @@ struct _ClutterMainContext
#define CLUTTER_CONTEXT() (clutter_context_get_default ())
ClutterMainContext *clutter_context_get_default (void);
#define CLUTTER_PRIVATE_FLAGS(a) (CLUTTER_ACTOR ((a))->private_flags)
#define CLUTTER_SET_PRIVATE_FLAGS(a,f) G_STMT_START{ (CLUTTER_PRIVATE_FLAGS (a) |= (f)); }G_STMT_END
#define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) G_STMT_START{ (CLUTTER_PRIVATE_FLAGS (a) &= ~(f)); }G_STMT_END
#define CLUTTER_PRIVATE_FLAGS(a) (((ClutterActor *) (a))->private_flags)
#define CLUTTER_SET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) |= (f))
#define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) &= ~(f))
#define CLUTTER_PARAM_READABLE \
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB

View File

@ -132,6 +132,8 @@ clutter_backend_egl_dispose (GObject *gobject)
if (backend_egl->stage)
{
CLUTTER_UNSET_PRIVATE_FLAGS (backend_egl->stage,
CLUTTER_ACTOR_IS_TOPLEVEL);
clutter_actor_destroy (backend_egl->stage);
backend_egl->stage = NULL;
}

View File

@ -24,6 +24,7 @@
#include "clutter-osx.h"
#include "clutter-backend-osx.h"
#include "clutter-stage-osx.h"
#include "../clutter-private.h"
#include <clutter/clutter-debug.h>
#import <AppKit/AppKit.h>
@ -145,6 +146,7 @@ clutter_backend_osx_dispose (GObject *object)
if (self->stage)
{
CLUTTER_UNSET_PRIVATE_FLAGS (self->stage, CLUTTER_ACTOR_IS_TOPLEVEL);
clutter_actor_destroy (self->stage);
self->stage = NULL;
}

View File

@ -148,6 +148,8 @@ clutter_backend_sdl_dispose (GObject *gobject)
if (backend_sdl->stage)
{
CLUTTER_UNSET_PRIVATE_FLAGS (backend_sdl->stage,
CLUTTER_ACTOR_IS_TOPLEVEL);
clutter_actor_destroy (backend_sdl->stage);
backend_sdl->stage = NULL;
}

View File

@ -245,6 +245,11 @@ clutter_backend_x11_dispose (GObject *gobject)
{
CLUTTER_NOTE (BACKEND, "Disposing the main stage");
/* we unset the private flag on the stage so we can safely
* destroy it without a warning from clutter_actor_destroy()
*/
CLUTTER_UNSET_PRIVATE_FLAGS (backend_x11->stage,
CLUTTER_ACTOR_IS_TOPLEVEL);
clutter_actor_destroy (backend_x11->stage);
backend_x11->stage = NULL;
}