[Swfdec-commits] 2 commits - src/swfmoz_loader.c src/swfmoz_loader.h src/swfmoz_player.c

Benjamin Otte company at kemper.freedesktop.org
Wed Aug 27 02:57:19 PDT 2008


 src/swfmoz_loader.c |   14 +++++++-------
 src/swfmoz_loader.h |    2 +-
 src/swfmoz_player.c |   27 +++++++++++++++++++--------
 3 files changed, 27 insertions(+), 16 deletions(-)

New commits:
commit 6365d5286ffb898fb3049b9e8d1694515c3f39f6
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Aug 27 11:54:19 2008 +0200

    store pointer to NPP in loaders (fixes 16822)
    
    That way we can set the NPP to NULL in the player and loaders get notified of
    it. This is not a beautiful way (storing a weak ref to the player would likely
    be better), but I'm lazy right now.

diff --git a/src/swfmoz_loader.c b/src/swfmoz_loader.c
index 01c0757..98361d6 100644
--- a/src/swfmoz_loader.c
+++ b/src/swfmoz_loader.c
@@ -56,7 +56,7 @@ swfmoz_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
   SwfmozLoader *moz = SWFMOZ_LOADER (loader);
 
   moz->waiting_for_stream = TRUE;
-  moz->instance = mozplay->instance;
+  moz->instance = &mozplay->instance;
   if (mozplay->initial) {
     swfmoz_loader_set_stream (moz, mozplay->initial);
     mozplay->initial = NULL;
@@ -68,12 +68,12 @@ swfmoz_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
 
       combined = swfmoz_player_add_headers (buffer, header_count, header_names,
 	  header_values);
-      plugin_post_url_notify (moz->instance, url, NULL, (char *)combined->data,
+      plugin_post_url_notify (*moz->instance, url, NULL, (char *)combined->data,
 	  combined->length, moz);
       swfdec_buffer_unref (combined);
     } else {
       // FIXME: Impossible to set headers here?
-      plugin_get_url_notify (moz->instance, url, NULL, moz);
+      plugin_get_url_notify (*moz->instance, url, NULL, moz);
     }
   }
 }
@@ -85,8 +85,8 @@ swfmoz_loader_close (SwfdecStream *stream)
 
   moz->waiting_for_stream = FALSE;
 
-  if (moz->stream)
-    plugin_destroy_stream (moz->instance, moz->stream);
+  if (*moz->instance && moz->stream)
+    plugin_destroy_stream (*moz->instance, moz->stream);
 }
 
 static void
@@ -116,7 +116,7 @@ swfmoz_loader_set_stream (SwfmozLoader *loader, NPStream *stream)
   g_return_if_fail (stream != NULL);
 
   if (!loader->waiting_for_stream) {
-    plugin_destroy_stream (loader->instance, stream);
+    plugin_destroy_stream (*loader->instance, stream);
     return;
   }
 
@@ -138,7 +138,7 @@ swfmoz_loader_ensure_open (SwfmozLoader *loader)
   if (loader->open)
     return;
   swfdec_loader_set_url (SWFDEC_LOADER (loader), loader->stream->url);
-  swfmoz_player_add_loader (loader->instance->pdata, loader);
+  swfmoz_player_add_loader ((*loader->instance)->pdata, loader);
   swfdec_stream_open (SWFDEC_STREAM (loader));
   loader->open = TRUE;
 }
diff --git a/src/swfmoz_loader.h b/src/swfmoz_loader.h
index d1c4e25..177f39e 100644
--- a/src/swfmoz_loader.h
+++ b/src/swfmoz_loader.h
@@ -40,7 +40,7 @@ struct _SwfmozLoader
 {
   SwfdecLoader		parent;
 
-  NPP			instance;	/* instance we belong to */
+  NPP *			instance;	/* pointer to instance we belong to or to NULL if we don't belong to any instance */
   NPStream *		stream;		/* stream we do or NULL if not created yet */
   gboolean		initial;	/* we are the initial loader */
 
diff --git a/src/swfmoz_player.c b/src/swfmoz_player.c
index aee6dce..1040431 100644
--- a/src/swfmoz_player.c
+++ b/src/swfmoz_player.c
@@ -617,7 +617,7 @@ swfmoz_player_loaders_update (GtkListStore *store, GtkTreeIter *iter, SwfdecLoad
   }
 
   url = swfdec_loader_get_url (loader);
-  player = SWFMOZ_LOADER (loader)->instance->pdata;
+  player = (*SWFMOZ_LOADER (loader)->instance)->pdata;
   if (url && SWFMOZ_LOADER (loader)->initial && swfdec_player_get_variables (player)) {
     /* This auto-appends the FlashVars to the reported URL. You should be able
      * to copy/paste that URL easily without breakage that way 
@@ -1001,6 +1001,7 @@ swfmoz_player_remove (SwfmozPlayer *player)
   swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (player), FALSE);
   swfdec_gtk_player_set_audio_enabled (SWFDEC_GTK_PLAYER (player), FALSE);
   swfmoz_dialog_remove (player);
+  player->instance = NULL;
   g_object_unref (player);
 }
 
commit 7eaefe278f8c486a4435e00e5a5a380b1a93afb8
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Aug 27 11:08:18 2008 +0200

    don't try to repaint stuff if there's no target to paint on
    
    First part of a fix for bug 16822

diff --git a/src/swfmoz_player.c b/src/swfmoz_player.c
index b1685af..aee6dce 100644
--- a/src/swfmoz_player.c
+++ b/src/swfmoz_player.c
@@ -244,6 +244,9 @@ swfmoz_player_redraw (SwfmozPlayer *player,
   GdkRegion *region;
   guint i;
 
+  if (player->target == NULL)
+    return;
+
   if (player->repaint)
     region = player->repaint;
   else
@@ -482,6 +485,18 @@ swfmoz_player_set_property (GObject *object, guint param_id, const GValue *value
 }
 
 static void
+swfmoz_player_clear_repaints (SwfmozPlayer *player)
+{
+  if (player->repaint_source) {
+    g_source_destroy (player->repaint_source);
+    g_source_unref (player->repaint_source);
+    player->repaint_source = NULL;
+    gdk_region_destroy (player->repaint);
+    player->repaint = NULL;
+  }
+}
+
+static void
 swfmoz_player_dispose (GObject *object)
 {
   SwfmozPlayer *player = SWFMOZ_PLAYER (object);
@@ -508,13 +523,7 @@ swfmoz_player_dispose (GObject *object)
     g_object_unref (player->target);
     player->target = NULL;
   }
-  if (player->repaint_source) {
-    g_source_destroy (player->repaint_source);
-    g_source_unref (player->repaint_source);
-    player->repaint_source = NULL;
-    gdk_region_destroy (player->repaint);
-    player->repaint = NULL;
-  }
+  swfmoz_player_clear_repaints (player);
   if (player->initial) {
     g_object_unref (player->initial);
     player->initial = NULL;
@@ -720,6 +729,7 @@ swfmoz_player_set_target (SwfmozPlayer *player, GdkWindow *target,
       g_object_unref (player->target);
     }
     player->target = target;
+    swfmoz_player_clear_repaints (player);
     if (target) {
       cairo_t *cr;
       SwfdecRenderer *renderer;


More information about the Swfdec-commits mailing list