[Swfdec] Branch 'as' - libswfdec/swfdec_flv_decoder.c libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_sprite_movie_as.c

Benjamin Otte company at kemper.freedesktop.org
Sat Jun 9 15:19:04 PDT 2007


 libswfdec/swfdec_flv_decoder.c     |    2 +-
 libswfdec/swfdec_movie.c           |   11 +++++++----
 libswfdec/swfdec_movie.h           |    4 +++-
 libswfdec/swfdec_sprite_movie_as.c |    4 ++--
 4 files changed, 13 insertions(+), 8 deletions(-)

New commits:
diff-tree d3ff93817f2931e6f6e9bb8400fe807c92e8f414 (from a84be08c2e1e412e3f1d7d485458dafc661411d1)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Jun 10 00:19:15 2007 +0200

    add a free flag to SwfdecContent

diff --git a/libswfdec/swfdec_flv_decoder.c b/libswfdec/swfdec_flv_decoder.c
index d9fc7f9..2352471 100644
--- a/libswfdec/swfdec_flv_decoder.c
+++ b/libswfdec/swfdec_flv_decoder.c
@@ -653,8 +653,8 @@ swfdec_flv_decoder_add_movie (SwfdecFlvD
   video->width = G_MAXUINT;
   video->height = G_MAXUINT;
   content->graphic = SWFDEC_GRAPHIC (video);
+  content->free = TRUE;
   movie = swfdec_movie_new (parent, content);
-  g_object_weak_ref (G_OBJECT (movie), (GWeakNotify) swfdec_content_free, content);
   g_object_weak_ref (G_OBJECT (movie), (GWeakNotify) g_object_unref, video);
   g_signal_connect (SWFDEC_ROOT_MOVIE (parent)->player, "notify::initialized",
       G_CALLBACK (notify_initialized), movie);
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index b33eff7..908e0ef 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -220,12 +220,13 @@ swfdec_movie_set_content (SwfdecMovie *m
 {
   g_return_if_fail (SWFDEC_IS_MOVIE (movie));
 
+  if (content == NULL)
+    content = &default_content;
+
   if (movie->content == content)
     return;
 
-  if (content == NULL) {
-    content = &default_content;
-  } else if (movie->content != &default_content) {
+  if (movie->content != &default_content && content != &default_content) {
     g_return_if_fail (movie->depth == content->depth);
     g_return_if_fail (movie->content->graphic == content->graphic);
     if (content->name) {
@@ -239,6 +240,8 @@ swfdec_movie_set_content (SwfdecMovie *m
   }
   SWFDEC_LOG ("setting content of movie %s from %p to %p", 
       movie->name, movie->content, content);
+  if (movie->content->free)
+    swfdec_content_free ((SwfdecContent *) movie->content);
   movie->content = content;
   if (!movie->modified) {
     movie->matrix = content->transform;
@@ -994,7 +997,7 @@ swfdec_movie_new_for_player (SwfdecPlaye
   content = swfdec_content_new ((int) depth - 16384);
   content->name = g_strdup_printf ("_level%u", depth);
   ret = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, NULL);
-  g_object_weak_ref (G_OBJECT (ret), (GWeakNotify) swfdec_content_free, content);
+  content->free = TRUE;
   if (swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), sizeof (SwfdecSpriteMovie))) {
     g_object_ref (ret);
     swfdec_as_object_add (SWFDEC_AS_OBJECT (ret),
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index 5053fc2..9c3aa62 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -62,9 +62,11 @@ struct _SwfdecContent {
   /* NB: the next two elements are only filled for the sequence leader */
   guint			start;		/* first frame that contains this sequence */
   guint			end;		/* first frame that does not contain this sequence anymore */
+
+  gboolean		free;		/* free when unsetting */
 };
 #define SWFDEC_CONTENT_DEFAULT { NULL, -1, 0, 0, { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, \
-  { 256, 0, 256, 0, 256, 0, 256, 0 }, NULL, NULL, CAIRO_OPERATOR_OVER, NULL, 0, G_MAXUINT }
+  { 256, 0, 256, 0, 256, 0, 256, 0 }, NULL, NULL, CAIRO_OPERATOR_OVER, NULL, 0, G_MAXUINT, FALSE }
 
 #define SWFDEC_TYPE_MOVIE                    (swfdec_movie_get_type())
 #define SWFDEC_IS_MOVIE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE))
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 4de0225..6141dcc 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -315,8 +315,8 @@ swfdec_sprite_movie_attachMovie (SwfdecA
   content->sequence = content;
   content->start = 0;
   content->end = G_MAXUINT;
+  content->free = TRUE;
   ret = swfdec_movie_new (movie, content);
-  g_object_weak_ref (G_OBJECT (ret), (GWeakNotify) swfdec_content_free, content);
   SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
       ret->name, ret->depth);
   /* run init and construct */
@@ -355,8 +355,8 @@ swfdec_sprite_movie_duplicateMovieClip (
   content->sequence = content;
   content->start = 0;
   content->end = G_MAXUINT;
+  content->free = TRUE;
   ret = swfdec_movie_new (movie->parent, content);
-  g_object_weak_ref (G_OBJECT (ret), (GWeakNotify) swfdec_content_free, content);
   /* must be set by now, the movie has a name */
   swfdec_sprite_movie_copy_props (ret, movie);
   SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, ret->name, ret->depth);


More information about the Swfdec mailing list