]> spindle.queued.net Git - midori/commitdiff
Share one session among all KatzeNet instances
authorChristian Dywan <christian@twotoasts.de>
Sun, 7 Dec 2008 20:36:42 +0000 (21:36 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 7 Dec 2008 20:36:42 +0000 (21:36 +0100)
katze/katze-net.c
midori/midori-view.c

index 0df4e2dc78204debe8c7fe8f40fbb0d9b3fa48c5..d8b0a405e43536c7230e6d6b3ce78f68c29c05c5 100644 (file)
@@ -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;
 }
index a125d5ecb65e81037a3e8f6127059dc690a5909c..9e03bdf3fd1a5eb59f1f62fa0758624e1b035182 100644 (file)
@@ -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,