Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19366/mozilla-plugin/src
Modified Files:
openvrml.cpp
Log Message:
Throw std::runtime_error in response to failures from GLib functions.
Index: openvrml.cpp
===================================================================
RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** openvrml.cpp 12 Oct 2006 07:39:01 -0000 1.41
--- openvrml.cpp 12 Oct 2006 08:57:30 -0000 1.42
***************
*** 91,95 ****
~plugin_instance() throw ();
! void set_window(NPWindow & window) throw (std::bad_alloc);
void HandleEvent(void * event) throw ();
ssize_t write_command(const std::string & command);
--- 91,96 ----
~plugin_instance() throw ();
! void set_window(NPWindow & window)
! throw (std::bad_alloc, std::runtime_error);
void HandleEvent(void * event) throw ();
ssize_t write_command(const std::string & command);
***************
*** 417,420 ****
--- 418,424 ----
} catch (std::bad_alloc &) {
return NPERR_OUT_OF_MEMORY_ERROR;
+ } catch (std::runtime_error & ex) {
+ g_critical(ex.what());
+ return NPERR_GENERIC_ERROR;
}
return NPERR_NO_ERROR;
***************
*** 1092,1096 ****
void plugin_instance::set_window(NPWindow & window)
! throw (std::bad_alloc)
{
assert(window.window);
--- 1096,1100 ----
void plugin_instance::set_window(NPWindow & window)
! throw (std::bad_alloc, std::runtime_error)
{
assert(window.window);
***************
*** 1132,1135 ****
--- 1136,1140 ----
} else {
GError * error = 0;
+ scope_guard error_guard = make_guard(g_error_free, error);
gboolean succeeded =
g_shell_parse_argv(openvrml_gtkplug_cmd,
***************
*** 1138,1146 ****
&error);
if (!succeeded) {
! if (error) {
! g_critical(error->message);
! g_error_free(error);
! }
}
}
--- 1143,1151 ----
&error);
if (!succeeded) {
! throw std::runtime_error(error
! ? error->message
! : "g_shell_parse_argv failure");
}
+ error_guard.dismiss();
}
***************
*** 1174,1177 ****
--- 1179,1183 ----
gint * const standard_error = 0;
GError * error = 0;
+ scope_guard error_guard = make_guard(g_error_free, error);
gboolean succeeded = g_spawn_async_with_pipes(working_dir,
argv,
***************
*** 1186,1196 ****
&error);
if (!succeeded) {
! if (error) {
! g_critical(error->message);
! g_error_free(error);
! }
! return;
}
this->command_channel = g_io_channel_unix_new(standard_input);
if (!this->command_channel) { throw std::bad_alloc(); }
--- 1192,1204 ----
&error);
if (!succeeded) {
! throw std::runtime_error(error
! ? error->message
! : "g_spawn_async_with_pipes failure");
}
+ //
+ // Don't dismiss "error_guard" yet; we reuse "error" below.
+ //
+
this->command_channel = g_io_channel_unix_new(standard_input);
if (!this->command_channel) { throw std::bad_alloc(); }
***************
*** 1200,1212 ****
&error);
if (status != G_IO_STATUS_NORMAL) {
! if (error) {
! g_critical(error->message);
! g_error_free(error);
! }
! // XXX
! // XXX Should probably throw here instead.
! // XXX
return;
}
this->request_channel = g_io_channel_unix_new(standard_output);
--- 1208,1217 ----
&error);
if (status != G_IO_STATUS_NORMAL) {
! throw std::runtime_error(error
! ? error->message
! : "g_io_channel_set_encoding failure");
return;
}
+ error_guard.dismiss();
this->request_channel = g_io_channel_unix_new(standard_output);
|