From: Christian Dywan Date: Sun, 7 Dec 2008 20:36:42 +0000 (+0100) Subject: Share one session among all KatzeNet instances X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=191a613fc89f443cbb11160948723adc7d9ab48e;p=midori Share one session among all KatzeNet instances --- diff --git a/katze/katze-net.c b/katze/katze-net.c index 0df4e2dc..d8b0a405 100644 --- a/katze/katze-net.c +++ b/katze/katze-net.c @@ -61,13 +61,19 @@ katze_net_object_maybe_unref (gpointer object) static void katze_net_init (KatzeNet* net) { + #if HAVE_LIBSOUP + static SoupSession* session = NULL; + #endif + net->memory = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, katze_net_object_maybe_unref); net->cache_path = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME, NULL); #if HAVE_LIBSOUP - net->session = soup_session_async_new (); + if (!session) + session = soup_session_async_new (); + net->session = session; #endif } @@ -85,17 +91,19 @@ katze_net_finalize (GObject* object) /** * katze_net_new: * - * Instantiates a new #KatzeNet singleton. - * - * Subsequent calls will ref the initial instance. + * Instantiates a new #KatzeNet instance. * * Return value: a new #KatzeNet **/ KatzeNet* katze_net_new (void) { - KatzeNet* net = g_object_new (KATZE_TYPE_NET, - NULL); + static KatzeNet* net = NULL; + + if (!net) + net = g_object_new (KATZE_TYPE_NET, NULL); + else + g_object_ref (net); return net; } diff --git a/midori/midori-view.c b/midori/midori-view.c index a125d5ec..9e03bdf3 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -502,7 +502,7 @@ midori_view_class_init (MidoriViewClass* class) "Net", "The associated net", KATZE_TYPE_NET, - G_PARAM_READWRITE)); + flags)); } static void @@ -1098,8 +1098,6 @@ midori_view_init (MidoriView* view) view->download_manager = NULL; - view->net = katze_net_new (); - g_object_connect (view, "signal::notify::icon", midori_view_notify_icon_cb, NULL,