[Xfce4-commits] <midori:master> Fix wrong unref in session saving, add timeout testing

Christian Dywan noreply at xfce.org
Fri Dec 7 20:20:02 CET 2012


Updating branch refs/heads/master
         to 08d8ceb253f8e5ac47340678e292e6c17b5bbb61 (commit)
       from b4122d4ba156889abea7d4f6db5092c5484debda (commit)

commit 08d8ceb253f8e5ac47340678e292e6c17b5bbb61
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Dec 7 18:50:21 2012 +0100

    Fix wrong unref in session saving, add timeout testing
    
    Midori.Test.idle_timeouts is a hook for unit tests to change
    second timeouts into idle callbacks.

 extensions/cookie-manager/cookie-manager.c |    3 ++-
 extensions/feed-panel/main.c               |    5 ++---
 katze/katze-http-cookies.c                 |    5 +++--
 midori/midori-browser.c                    |    3 ++-
 midori/midori-dialog.vala                  |   13 +++++++++++++
 midori/midori-session.c                    |    5 ++---
 tests/app.vala                             |    6 ++++++
 7 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/extensions/cookie-manager/cookie-manager.c b/extensions/cookie-manager/cookie-manager.c
index 4ca57ca..18f4c0d 100644
--- a/extensions/cookie-manager/cookie-manager.c
+++ b/extensions/cookie-manager/cookie-manager.c
@@ -234,7 +234,8 @@ static void cookie_manager_jar_changed_cb(SoupCookieJar *jar, SoupCookie *old, S
 	/* We delay these events a little bit to avoid too many rebuilds of the tree.
 	 * Some websites (like Flyspray bugtrackers sent a whole bunch of cookies at once. */
 	if (priv->timer_id == 0)
-		priv->timer_id = g_timeout_add_seconds(1, (GSourceFunc) cookie_manager_delayed_refresh, cm);
+		priv->timer_id = midori_timeout_add_seconds(
+			1, (GSourceFunc) cookie_manager_delayed_refresh, cm, NULL);
 }
 
 
diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c
index 8cad47a..bff7bd9 100644
--- a/extensions/feed-panel/main.c
+++ b/extensions/feed-panel/main.c
@@ -16,7 +16,6 @@
 #include <midori/midori.h>
 
 #define EXTENSION_NAME "Feed Panel"
-#define UPDATE_FREQ 10
 
 #define feed_get_flags(feed) \
     GPOINTER_TO_INT (g_object_get_data (G_OBJECT ((feed)), "flags"))
@@ -488,8 +487,8 @@ feed_app_add_browser_cb (MidoriApp*       app,
     g_signal_connect (extension, "deactivate",
         G_CALLBACK (feed_deactivate_cb), priv);
 
-    priv->source_id = g_timeout_add_seconds (UPDATE_FREQ * 60,
-                            (GSourceFunc) update_feeds, priv);
+    priv->source_id = midori_timeout_add_seconds (
+        600, (GSourceFunc) update_feeds, priv, NULL);
 }
 
 static void
diff --git a/katze/katze-http-cookies.c b/katze/katze-http-cookies.c
index 1ccb8d9..ac77130 100644
--- a/katze/katze-http-cookies.c
+++ b/katze/katze-http-cookies.c
@@ -14,6 +14,7 @@
 #endif
 
 #include "katze-http-cookies.h"
+#include "midori/midori-core.h"
 
 #include <stdlib.h>
 #ifdef HAVE_UNISTD_H
@@ -267,8 +268,8 @@ katze_http_cookies_jar_changed_cb (SoupCookieJar*    jar,
         http_cookies->counter++;
 
     if (!http_cookies->timeout && (old_cookie || new_cookie->expires))
-        http_cookies->timeout = g_timeout_add_seconds (5,
-            (GSourceFunc)katze_http_cookies_update_jar, http_cookies);
+        http_cookies->timeout = midori_timeout_add_seconds (
+            5, (GSourceFunc)katze_http_cookies_update_jar, http_cookies, NULL);
 }
 
 static void
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 55b0c40..c773c51 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -5502,7 +5502,8 @@ midori_browser_set_inactivity_reset (MidoriBrowser* browser,
         MidoriInactivityTimeout* mit = g_new (MidoriInactivityTimeout, 1);
         mit->browser = browser;
         mit->timeout = inactivity_reset;
-        g_timeout_add_seconds (inactivity_reset, midori_inactivity_timeout, mit);
+        midori_timeout_add_seconds (
+            inactivity_reset, midori_inactivity_timeout, mit, NULL);
     }
 }
 
diff --git a/midori/midori-dialog.vala b/midori/midori-dialog.vala
index 48d6405..5fd4611 100644
--- a/midori/midori-dialog.vala
+++ b/midori/midori-dialog.vala
@@ -10,7 +10,20 @@
 */
 
 namespace Midori {
+    namespace Timeout {
+        public uint add_seconds (uint interval, owned SourceFunc function) {
+            if (Test.test_idle_timeouts)
+                return GLib.Idle.add (function);
+            return GLib.Timeout.add_seconds (interval, function);
+        }
+    }
+
     namespace Test {
+        internal static bool test_idle_timeouts = false;
+        public void idle_timeouts () {
+            test_idle_timeouts = true;
+        }
+
         public void log_set_fatal_handler_for_icons () {
             GLib.Test.log_set_fatal_handler ((domain, log_levels, message)=> {
                 return !message.contains ("Error loading theme icon")
diff --git a/midori/midori-session.c b/midori/midori-session.c
index 4c480f3..be2f09a 100644
--- a/midori/midori-session.c
+++ b/midori/midori-session.c
@@ -427,8 +427,6 @@ midori_session_save_timeout_cb (KatzeArray* session)
     g_free (config_file);
 
     save_timeout = 0;
-    g_object_unref (session);
-
     return FALSE;
 }
 
@@ -438,7 +436,8 @@ midori_browser_session_cb (MidoriBrowser* browser,
                            KatzeArray*    session)
 {
     if (!save_timeout)
-        save_timeout = g_timeout_add_seconds (5, (GSourceFunc)midori_session_save_timeout_cb, session);
+        save_timeout = midori_timeout_add_seconds (
+            5, (GSourceFunc)midori_session_save_timeout_cb, session, NULL);
 }
 
 static void
diff --git a/tests/app.vala b/tests/app.vala
index ea6a645..b72c982 100644
--- a/tests/app.vala
+++ b/tests/app.vala
@@ -10,11 +10,17 @@
 */
 
 void app_normal () {
+    Midori.Test.idle_timeouts ();
     Midori.Test.log_set_fatal_handler_for_icons ();
     Midori.Paths.Test.reset_runtime_mode ();
     var app = Midori.normal_app_new (null, false, false, null, null, null, -1, null);
     var loop = MainContext.default ();
     do { loop.iteration (true); } while (loop.pending ());
+    for (var i = 0 ; i < 7; i++) {
+        var tab = app.browser.get_nth_tab (app.browser.add_uri ("about:blank"));
+        app.browser.close_tab (tab);
+        do { loop.iteration (true); } while (loop.pending ());
+    }
     Midori.normal_app_on_quit (app);
 
     string filename = Midori.Paths.get_extension_config_dir ("adblock");


More information about the Xfce4-commits mailing list