Mercurial > hg > octave-nkf
changeset 17473:9849075a5da6
allow objects to load if constructor fails but loadobj method succeeds
* ov-class.cc (octave_class::reconstruct_exemplar): Don't throw error
if constructor execution fails.
(octave_class::load_ascii, octave_class::load_binary,
octave_class::load_hdf5): Attempt to handle exemplar and loadobj
method consistently.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 24 Sep 2013 16:41:20 -0400 |
parents | bddb9688e41c |
children | 6edc451629a6 |
files | libinterp/octave-value/ov-class.cc |
diffstat | 1 files changed, 36 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-class.cc +++ b/libinterp/octave-value/ov-class.cc @@ -1239,13 +1239,19 @@ if (have_ctor) { + unwind_protect frame; + + // Simulate try/catch. + + interpreter_try (frame); + octave_value_list result = ctor.do_multi_index_op (1, octave_value_list ()); - if (result.length () == 1) + if (! error_state && result.length () == 1) retval = true; - else - warning ("call to constructor for class %s failed", c_name.c_str ()); + + error_state = false; } else warning ("no constructor for class %s", c_name.c_str ()); @@ -1401,19 +1407,17 @@ if (! reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else + + if (load_path::find_method (classname, "loadobj") + != std::string ()) { - if (load_path::find_method (classname, "loadobj") - != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - map = tmp(0).map_value (); - else - success = false; - } + if (! error_state) + map = tmp(0).map_value (); + else + success = false; } } else @@ -1548,18 +1552,16 @@ if (! reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else + + if (load_path::find_method (c_name, "loadobj") != std::string ()) { - if (load_path::find_method (c_name, "loadobj") != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - map = tmp(0).map_value (); - else - success = false; - } + if (! error_state) + map = tmp(0).map_value (); + else + success = false; } } else @@ -1788,23 +1790,19 @@ if (!reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else - { - if (load_path::find_method (c_name, "loadobj") != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - { - map = tmp(0).map_value (); - retval = true; - } - else - retval = false; + if (load_path::find_method (c_name, "loadobj") != std::string ()) + { + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); + + if (! error_state) + { + map = tmp(0).map_value (); + retval = true; } else - retval = true; + retval = false; } }