]> git.decadent.org.uk Git - videolink.git/commitdiff
Fixed initial reference count for null_prompt_service instances so that fatal error...
authorBen Hutchings <ben@decadent.org.uk>
Mon, 7 Aug 2006 23:11:53 +0000 (23:11 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 2 Nov 2008 23:40:01 +0000 (23:40 +0000)
Corrected abuse of glib/gtk event loop revealed by fatal error report for initial URL.

TODO
null_prompt_service.cpp
webdvd.cpp

diff --git a/TODO b/TODO
index 7bf02e232b593518d61886ea566998f7b1e03ab8..072cba3ca77f4b8f00dca399236546c1a6f957c2 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 Priority 1 (highest)
-Investigate and fix the crash that occurs after we trigger exit from null_prompt_service.
 
 Priority 2
 Use ffmpeg to convert unsuitable video files (how do we check this?).
index 878f7ff268f71057127e1f997287ad0b024d0077..37303c054a089211e373c4158d5de66f7af8b439 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright 2006 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
+#include <new>
 #include <string>
 
 #include <langinfo.h>
@@ -36,12 +37,14 @@ namespace
        if (!iid.Equals(prompt_service_iid))
            return NS_ERROR_NO_INTERFACE;
 
-       try
+       if (null_prompt_service * service =
+               new (std::nothrow) null_prompt_service)
        {
-           *result = new null_prompt_service;
+           service->AddRef();
+           *result = service;
            return NS_OK;
        }
-       catch (std::bad_alloc &)
+       else
        {
            return NS_ERROR_OUT_OF_MEMORY;
        }
index 66c70caddaa5897fe5ef864d1732b40451c73c61..fa94ccb90abcd410b4ceed506dd2e6ec2bdf7878 100644 (file)
@@ -169,6 +169,7 @@ namespace
        dvd_contents::pgc_ref add_menu(const std::string & uri);
        dvd_contents::pgc_ref add_title(const std::string & uri);
        void load_next_page();
+       bool on_idle();
        void on_net_state_change(const char * uri, gint flags, guint status);
        bool browser_is_busy() const
            {
@@ -220,11 +221,12 @@ namespace
 
        add(browser_widget_);
        browser_widget_.show();
+       Glib::signal_idle().connect(
+           SigC::slot(*this, &webdvd_window::on_idle));
        browser_widget_.signal_net_state().connect(
            SigC::slot(*this, &webdvd_window::on_net_state_change));
 
        add_menu(main_page_uri);
-       load_next_page();
     }
 
     bool webdvd_window::is_finished() const
@@ -302,6 +304,12 @@ namespace
        browser_widget_.load_uri(uri);
     }
 
+    bool webdvd_window::on_idle()
+    {
+       load_next_page();
+       return false; // don't call again thankyou
+    }
+
     void webdvd_window::on_net_state_change(const char * uri,
                                           gint flags, guint status)
     {
@@ -1033,7 +1041,9 @@ int main(int argc, char ** argv)
 
        // Run the browser/converter
        webdvd_window window(frame_params, menu_url, output_dir, encoder);
-       Gtk::Main::run(window);
+       window.show();
+       window.signal_hide().connect(SigC::slot(&Gtk::Main::quit));
+       Gtk::Main::run();
 
        return ((preview_mode || window.is_finished())
                ? EXIT_SUCCESS