From 6e994af0a7e236de8d3e4dbfed0219f7fc3e1dbf Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 7 Aug 2006 23:11:53 +0000 Subject: [PATCH] Fixed initial reference count for null_prompt_service instances so that fatal error reports are not followed by a crash. Corrected abuse of glib/gtk event loop revealed by fatal error report for initial URL. --- TODO | 1 - null_prompt_service.cpp | 9 ++++++--- webdvd.cpp | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 7bf02e2..072cba3 100644 --- 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?). diff --git a/null_prompt_service.cpp b/null_prompt_service.cpp index 878f7ff..37303c0 100644 --- a/null_prompt_service.cpp +++ b/null_prompt_service.cpp @@ -1,6 +1,7 @@ // Copyright 2006 Ben Hutchings . // See the file "COPYING" for licence details. +#include #include #include @@ -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; } diff --git a/webdvd.cpp b/webdvd.cpp index 66c70ca..fa94ccb 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -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 -- 2.39.2