]> spindle.queued.net Git - midori/commitdiff
Initialize session in app/ private before adding URIs
authorChristian Dywan <christian@twotoasts.de>
Tue, 26 Jul 2011 23:19:48 +0000 (01:19 +0200)
committerChristian Dywan <christian@twotoasts.de>
Tue, 26 Jul 2011 23:23:56 +0000 (01:23 +0200)
If the session is not prepared properly URIs loading of
the first page(s) breaks. Also it is a good idea to sort
out all settings before loading anything to begin with.

You will now see "midori_load_soup_session was not called!" if
any pages try to load before the session is prepared.

Fixes: https://bugs.launchpad.net/midori/+bug/814268
midori/main.c
midori/midori-browser.c

index 3afa9c2eb9bd0200e9b5c65dc863507619a3a0f2..004906c7a5ad703b4f49da8c3ee7e20b69197f4a 100644 (file)
@@ -1021,6 +1021,8 @@ midori_load_soup_session (gpointer settings)
 
     midori_soup_session_debug (session);
 
+    g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
+
     return FALSE;
 }
 
@@ -2170,25 +2172,6 @@ main (int    argc,
         else
             settings = g_object_ref (midori_browser_get_settings (browser));
 
-        if (webapp)
-        {
-            gchar* tmp_uri = midori_prepare_uri (webapp);
-            g_object_set (settings,
-                          "show-menubar", FALSE,
-                          "show-navigationbar", FALSE,
-                          "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage",
-                          "homepage", tmp_uri,
-                          "show-statusbar", FALSE,
-                          "enable-developer-extras", FALSE,
-                          NULL);
-            midori_browser_set_action_visible (browser, "Menubar", FALSE);
-            midori_browser_add_uri (browser, tmp_uri);
-            g_free (tmp_uri);
-            /* Update window icon according to page */
-            g_signal_connect (browser, "notify::load-status",
-                G_CALLBACK (midori_web_app_browser_notify_load_status_cb), NULL);
-        }
-
         if (private)
         {
             g_object_set (settings,
@@ -2211,7 +2194,32 @@ main (int    argc,
             sokoke_set_config_dir ("/");
         }
 
-        g_object_set (settings, "show-panel", FALSE,
+        midori_load_soup_session (settings);
+        if (block_uris)
+            g_signal_connect (session, "request-queued",
+                G_CALLBACK (midori_soup_session_block_uris_cb),
+                g_strdup (block_uris));
+
+        if (webapp)
+        {
+            gchar* tmp_uri = midori_prepare_uri (webapp);
+            g_object_set (settings,
+                          "show-menubar", FALSE,
+                          "show-navigationbar", FALSE,
+                          "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage",
+                          "homepage", tmp_uri,
+                          "show-statusbar", FALSE,
+                          "enable-developer-extras", FALSE,
+                          NULL);
+            midori_browser_set_action_visible (browser, "Menubar", FALSE);
+            midori_browser_add_uri (browser, tmp_uri);
+            g_free (tmp_uri);
+            /* Update window icon according to page */
+            g_signal_connect (browser, "notify::load-status",
+                G_CALLBACK (midori_web_app_browser_notify_load_status_cb), NULL);
+        }
+
+       g_object_set (settings, "show-panel", FALSE,
                       "last-window-state", MIDORI_WINDOW_NORMAL,
                       NULL);
         midori_browser_set_action_visible (browser, "Panel", FALSE);
@@ -2242,12 +2250,7 @@ main (int    argc,
         if (midori_browser_get_current_uri (browser) == NULL)
             midori_browser_add_uri (browser, "about:blank");
 
-        if (block_uris)
-            g_signal_connect (session, "request-queued",
-                G_CALLBACK (midori_soup_session_block_uris_cb),
-                g_strdup (block_uris));
         midori_setup_inactivity_reset (browser, inactivity_reset, webapp);
-        midori_load_soup_session (settings);
         midori_startup_timer ("App created: \t%f");
         gtk_main ();
         return 0;
index aafa450f8b23b11c7c51a813676cc343aecdbf99..a67fc0501d2c402cdef29d123606acc4e9fa4174 100644 (file)
@@ -6819,6 +6819,10 @@ midori_browser_add_tab (MidoriBrowser* browser,
     g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
     g_return_val_if_fail (GTK_IS_WIDGET (view), -1);
 
+    if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()),
+                            "midori-session-initialized"))
+        g_critical ("midori_load_soup_session was not called!");
+
     g_signal_emit (browser, signals[ADD_TAB], 0, view);
     return gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
 }