[Swfdec] 4 commits - libswfdec/swfdec_button.h libswfdec/swfdec_button_movie.c libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_sprite_movie.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 25 03:43:33 PDT 2007


 libswfdec/swfdec_button.h                 |   18 +++++++-------
 libswfdec/swfdec_button_movie.c           |   10 ++++----
 libswfdec/swfdec_resource.c               |   10 ++++----
 libswfdec/swfdec_resource.h               |    2 -
 libswfdec/swfdec_sprite_movie.c           |    3 --
 test/trace/Makefile.am                    |   37 ++++++++++++++++++------------
 test/trace/settarget-tostring-5.swf       |binary
 test/trace/settarget-tostring-5.swf.trace |    1 
 test/trace/settarget-tostring-6.swf       |binary
 test/trace/settarget-tostring-6.swf.trace |    1 
 test/trace/settarget-tostring-7.swf       |binary
 test/trace/settarget-tostring-7.swf.trace |    1 
 test/trace/settarget-tostring-8.swf       |binary
 test/trace/settarget-tostring-8.swf.trace |    1 
 test/trace/settarget-tostring.as          |    8 ++++++
 15 files changed, 56 insertions(+), 36 deletions(-)

New commits:
commit 45ecc75a9b754d2d5f8c42a18ae01d95de3e0a74
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 12:43:14 2007 +0200

    fix stupid refcounting issue that made memory freed while in use
    
    I should not optimize too early...

diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 1bbb201..7847f48 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -238,7 +238,8 @@ swfdec_resource_class_init (SwfdecResourceClass *klass)
 static void
 swfdec_resource_init (SwfdecResource *instance)
 {
-  instance->exports = g_hash_table_new (swfdec_str_case_hash, swfdec_str_case_equal);
+  instance->exports = g_hash_table_new_full (swfdec_str_case_hash, 
+      swfdec_str_case_equal, g_free, g_object_unref);
   instance->export_names = g_hash_table_new_full (g_direct_hash, g_direct_equal, 
       g_object_unref, g_free);
 }
@@ -290,15 +291,14 @@ swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *char
   return g_hash_table_lookup (instance->export_names, character);
 }
 
-/* NB: Takes ownership of name and character */
 void
-swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, char *name)
+swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
 {
   g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
   g_return_if_fail (SWFDEC_IS_CHARACTER (character));
   g_return_if_fail (name != NULL);
 
-  g_hash_table_insert (instance->exports, (char *) name, character);
-  g_hash_table_insert (instance->export_names, character, (char *) name);
+  g_hash_table_insert (instance->exports, g_strdup (name), g_object_ref (character));
+  g_hash_table_insert (instance->export_names, g_object_ref (character), g_strdup (name));
 }
 
diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h
index 1a38ea0..c87d205 100644
--- a/libswfdec/swfdec_resource.h
+++ b/libswfdec/swfdec_resource.h
@@ -65,7 +65,7 @@ void		swfdec_resource_set_movie		(SwfdecResource *	resource,
 
 void		swfdec_resource_add_export		(SwfdecResource *	instance,
 							 SwfdecCharacter *	character,
-							 char *			name);
+							 const char * 		name);
 gpointer	swfdec_resource_get_export		(SwfdecResource *	root,
 							 const char *		name);
 const char *	swfdec_resource_get_export_name    	(SwfdecResource *	root,
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 10fc011..e38a3e1 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -358,14 +358,13 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
 	  name = swfdec_bits_get_string_with_version (&bits, SWFDEC_AS_CONTEXT (player)->version);
 	  if (object == NULL) {
 	    SWFDEC_ERROR ("cannot export id %u as %s, id wasn't found", id, name);
-	    g_free (name);
 	  } else if (name == NULL) {
 	    SWFDEC_ERROR ("cannot export id %u, no name was given", id);
 	  } else {
 	    SWFDEC_LOG ("exporting %s %u as %s", G_OBJECT_TYPE_NAME (object), id, name);
-	    g_object_ref (object);
 	    swfdec_resource_add_export (resource, object, name); 
 	  }
+	  g_free (name);
 	}
       }
       return TRUE;
commit 361c097d00f3b4201557ff3c5cb2a180bf890336
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 12:15:42 2007 +0200

    fix button to work with changed event list behavior

diff --git a/libswfdec/swfdec_button.h b/libswfdec/swfdec_button.h
index 373f77c..8baa88f 100644
--- a/libswfdec/swfdec_button.h
+++ b/libswfdec/swfdec_button.h
@@ -46,15 +46,15 @@ typedef enum {
 
 /* these values have to be kept in line with condition parsing */
 typedef enum {
-  SWFDEC_BUTTON_IDLE_TO_OVER_UP = (1 << 0),
-  SWFDEC_BUTTON_OVER_UP_TO_IDLE = (1 << 1),
-  SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN = (1 << 2),
-  SWFDEC_BUTTON_OVER_DOWN_TO_OVER_UP = (1 << 3),
-  SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN = (1 << 4),
-  SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN = (1 << 5),
-  SWFDEC_BUTTON_OUT_DOWN_TO_IDLE = (1 << 6),
-  SWFDEC_BUTTON_IDLE_TO_OVER_DOWN = (1 << 7),
-  SWFDEC_BUTTON_OVER_DOWN_TO_IDLE = (1 << 8)
+  SWFDEC_BUTTON_IDLE_TO_OVER_UP = 0,
+  SWFDEC_BUTTON_OVER_UP_TO_IDLE = 1,
+  SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN = 2,
+  SWFDEC_BUTTON_OVER_DOWN_TO_OVER_UP = 3,
+  SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN = 4,
+  SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN = 5,
+  SWFDEC_BUTTON_OUT_DOWN_TO_IDLE = 6,
+  SWFDEC_BUTTON_IDLE_TO_OVER_DOWN = 7,
+  SWFDEC_BUTTON_OVER_DOWN_TO_IDLE = 8
 } SwfdecButtonCondition;
 
 struct _SwfdecButton {
diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c
index 3aad8fd..c6132a6 100644
--- a/libswfdec/swfdec_button_movie.c
+++ b/libswfdec/swfdec_button_movie.c
@@ -99,12 +99,12 @@ swfdec_button_movie_execute (SwfdecButtonMovie *movie,
   const char *name;
 
   if (movie->button->menubutton) {
-    g_assert ((condition & (SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN \
-                         | SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN \
-                         | SWFDEC_BUTTON_OUT_DOWN_TO_IDLE)) == 0);
+    g_assert ((condition & ((1 << SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN) \
+                         | (1 << SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN) \
+                         | (1 << SWFDEC_BUTTON_OUT_DOWN_TO_IDLE))) == 0);
   } else {
-    g_assert ((condition & (SWFDEC_BUTTON_IDLE_TO_OVER_DOWN \
-                         | SWFDEC_BUTTON_OVER_DOWN_TO_IDLE)) == 0);
+    g_assert ((condition & ((1 << SWFDEC_BUTTON_IDLE_TO_OVER_DOWN) \
+                         | (1 << SWFDEC_BUTTON_OVER_DOWN_TO_IDLE))) == 0);
   }
   if (movie->button->events)
     swfdec_event_list_execute (movie->button->events, 
commit 6f9acf14f630a2e058bb7ca30f6642a85583b180
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 12:01:57 2007 +0200

    alphabetic ordering is hard...

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 60faa06..3e7b9dd 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1373,29 +1373,6 @@ EXTRA_DIST = \
 	round-direction-7.swf.trace \
 	round-direction-8.swf \
 	round-direction-8.swf.trace \
-	settarget.as \
-	settarget-5.swf \
-	settarget-5.swf.trace \
-	settarget-6.swf \
-	settarget-6.swf.trace \
-	settarget-7.swf \
-	settarget-7.swf.trace \
-	settarget-tostring-5.swf
-	settarget-tostring-5.swf.trace
-	settarget-tostring-6.swf
-	settarget-tostring-6.swf.trace
-	settarget-tostring-7.swf
-	settarget-tostring-7.swf.trace
-	settarget-tostring-8.swf
-	settarget-tostring-8.swf.trace
-	settarget-tostring.as
-	settimeout.as \
-	settimeout-5.swf \
-	settimeout-5.swf.trace \
-	settimeout-6.swf \
-	settimeout-6.swf.trace \
-	settimeout-7.swf \
-	settimeout-7.swf.trace \
 	scalemode.as \
 	scalemode-5.swf \
 	scalemode-5.swf.trace \
@@ -1558,6 +1535,22 @@ EXTRA_DIST = \
 	settarget2-tostring-7.swf.trace \
 	settarget2-tostring-8.swf \
 	settarget2-tostring-8.swf.trace \
+	settarget.as \
+	settarget-5.swf \
+	settarget-5.swf.trace \
+	settarget-6.swf \
+	settarget-6.swf.trace \
+	settarget-7.swf \
+	settarget-7.swf.trace \
+	settarget-tostring-5.swf
+	settarget-tostring-5.swf.trace
+	settarget-tostring-6.swf
+	settarget-tostring-6.swf.trace
+	settarget-tostring-7.swf
+	settarget-tostring-7.swf.trace
+	settarget-tostring-8.swf
+	settarget-tostring-8.swf.trace
+	settarget-tostring.as
 	settarget-delimiters.as \
 	settarget-delimiters-5.swf \
 	settarget-delimiters-5.swf.trace \
@@ -1585,6 +1578,13 @@ EXTRA_DIST = \
 	settarget-relative-7.swf.trace \
 	settarget-relative-8.swf \
 	settarget-relative-8.swf.trace \
+	settimeout.as \
+	settimeout-5.swf \
+	settimeout-5.swf.trace \
+	settimeout-6.swf \
+	settimeout-6.swf.trace \
+	settimeout-7.swf \
+	settimeout-7.swf.trace \
 	setvariable.swf \
 	setvariable.swf.trace \
 	setvariable-callback.as \
commit a8228f8290786387b076a6829775aba781d5da08
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 12:01:02 2007 +0200

    add a test suggested on IRC

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index aa7b8e8..60faa06 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1380,6 +1380,15 @@ EXTRA_DIST = \
 	settarget-6.swf.trace \
 	settarget-7.swf \
 	settarget-7.swf.trace \
+	settarget-tostring-5.swf
+	settarget-tostring-5.swf.trace
+	settarget-tostring-6.swf
+	settarget-tostring-6.swf.trace
+	settarget-tostring-7.swf
+	settarget-tostring-7.swf.trace
+	settarget-tostring-8.swf
+	settarget-tostring-8.swf.trace
+	settarget-tostring.as
 	settimeout.as \
 	settimeout-5.swf \
 	settimeout-5.swf.trace \
diff --git a/test/trace/settarget-tostring-5.swf b/test/trace/settarget-tostring-5.swf
new file mode 100644
index 0000000..8bdd192
Binary files /dev/null and b/test/trace/settarget-tostring-5.swf differ
diff --git a/test/trace/settarget-tostring-5.swf.trace b/test/trace/settarget-tostring-5.swf.trace
new file mode 100644
index 0000000..417b7b5
--- /dev/null
+++ b/test/trace/settarget-tostring-5.swf.trace
@@ -0,0 +1 @@
+undefined
diff --git a/test/trace/settarget-tostring-6.swf b/test/trace/settarget-tostring-6.swf
new file mode 100644
index 0000000..eefeb75
Binary files /dev/null and b/test/trace/settarget-tostring-6.swf differ
diff --git a/test/trace/settarget-tostring-6.swf.trace b/test/trace/settarget-tostring-6.swf.trace
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/test/trace/settarget-tostring-6.swf.trace
@@ -0,0 +1 @@
+0
diff --git a/test/trace/settarget-tostring-7.swf b/test/trace/settarget-tostring-7.swf
new file mode 100644
index 0000000..17e4dca
Binary files /dev/null and b/test/trace/settarget-tostring-7.swf differ
diff --git a/test/trace/settarget-tostring-7.swf.trace b/test/trace/settarget-tostring-7.swf.trace
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/test/trace/settarget-tostring-7.swf.trace
@@ -0,0 +1 @@
+0
diff --git a/test/trace/settarget-tostring-8.swf b/test/trace/settarget-tostring-8.swf
new file mode 100644
index 0000000..51d3fe2
Binary files /dev/null and b/test/trace/settarget-tostring-8.swf differ
diff --git a/test/trace/settarget-tostring-8.swf.trace b/test/trace/settarget-tostring-8.swf.trace
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/test/trace/settarget-tostring-8.swf.trace
@@ -0,0 +1 @@
+0
diff --git a/test/trace/settarget-tostring.as b/test/trace/settarget-tostring.as
new file mode 100644
index 0000000..0413718
--- /dev/null
+++ b/test/trace/settarget-tostring.as
@@ -0,0 +1,8 @@
+// makeswf -v 7 -s 200x150 -r 1 -o settarget-tostring.swf settarget-tostring.as
+
+a = createEmptyMovieClip ("name", 0);
+b = createEmptyMovieClip ("name", 1);
+setTarget (b);
+trace (getDepth ());
+
+loadMovie ("fscommand:QUIT", "");


More information about the Swfdec mailing list