[libchamplain] Abort any pending network requests when the source is disposed
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Subject: [libchamplain] Abort any pending network requests when the source is disposed
- Date: Sat, 13 Jun 2009 19:04:56 -0400 (EDT)
commit 766cfbc9b6c4e5ceb03359ba7ef76762f1b58380
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date: Sat Jun 13 17:31:17 2009 -0400
Abort any pending network requests when the source is disposed
champlain/champlain-network-map-source.c | 25 +++++++++++++++++++++++--
demos/launcher-gtk.c | 8 ++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c
index 1d018a6..f3eed7c 100644
--- a/champlain/champlain-network-map-source.c
+++ b/champlain/champlain-network-map-source.c
@@ -152,6 +152,16 @@ champlain_network_map_source_set_property (GObject *object,
}
static void
+champlain_network_map_source_dispose (GObject *object)
+{
+ //ChamplainNetworkMapSource *source = CHAMPLAIN_NETWORK_MAP_SOURCE (object);
+ //ChamplainNetworkMapSourcePrivate *priv = source->priv;
+
+ if (soup_session != NULL)
+ soup_session_abort (soup_session);
+}
+
+static void
champlain_network_map_source_finalize (GObject *object)
{
ChamplainNetworkMapSource *source = CHAMPLAIN_NETWORK_MAP_SOURCE (object);
@@ -172,6 +182,7 @@ champlain_network_map_source_class_init (ChamplainNetworkMapSourceClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = champlain_network_map_source_finalize;
+ object_class->dispose = champlain_network_map_source_dispose;
object_class->get_property = champlain_network_map_source_get_property;
object_class->set_property = champlain_network_map_source_set_property;
@@ -426,7 +437,16 @@ file_loaded_cb (SoupSession *session,
filename = champlain_tile_get_filename (tile);
DEBUG ("Got reply %d", msg->status_code);
- if (msg->status_code == 304)
+ if (msg->status_code == SOUP_STATUS_CANCELLED)
+ {
+ DEBUG ("Download of tile %d, %d got cancelled",
+ champlain_tile_get_x (tile), champlain_tile_get_y (tile));
+ //champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
+ g_object_unref (tile);
+ return;
+ }
+
+ if (msg->status_code == SOUP_STATUS_NOT_MODIFIED)
{
/* Since we are updating the cache, we can assume that the directories
* exists */
@@ -586,7 +606,6 @@ fill_tile (ChamplainMapSource *map_source,
DEBUG ("Tile loaded from cache");
}
-
if ((in_cache == FALSE || (in_cache == TRUE && validate_cache == TRUE)) &&
priv->offline == FALSE)
{
@@ -608,6 +627,8 @@ fill_tile (ChamplainMapSource *map_source,
NULL);
g_object_set (G_OBJECT (soup_session), "user-agent", "libchamplain/"
CHAMPLAIN_VERSION_S, NULL);
+ g_object_add_weak_pointer (G_OBJECT (soup_session),
+ (gpointer *) &soup_session);
}
uri = champlain_network_map_source_get_tile_uri (source,
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index bbeb670..d31816b 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -177,6 +177,14 @@ build_combo_box (GtkComboBox *box)
"text", COL_NAME, NULL );
}
+static gboolean
+delete_window (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_main_quit ();
+}
+
int
main (int argc,
char *argv[])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]