# HG changeset patch # User John W. Eaton # Date 1213119815 14400 # Node ID b4ac6bb4114b03113ae38f29a3613aa0b52933fe # Parent 59031cfe331bd5ae4b81516c3b14023cfc1eb4e9 graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2008-06-09 John W. Eaton + * graphics.cc (execute_callback): Pass CB by const reference and + explicitly make a copy. + (xget_ancestor): Pass GO by const reference and explicitly make a copy. + * error.cc (verror): Omit "name: " and "\a" from Vlast_error_msg. Save line and column information from user code. * toplev.cc (octave_call_stack::do_caller_user_code_line, diff --git a/src/graphics.cc b/src/graphics.cc --- a/src/graphics.cc +++ b/src/graphics.cc @@ -188,12 +188,8 @@ xset_gcbo (graphics_handle ()); } -// NOTE: "cb" is passed by value, because "function_value" method -// is non-const; passing "cb" by const-reference is not -// possible - static void -execute_callback (octave_value cb, const graphics_handle& h, +execute_callback (const octave_value& cb_arg, const graphics_handle& h, const octave_value& data) { octave_value_list args; @@ -212,6 +208,10 @@ BEGIN_INTERRUPT_WITH_EXCEPTIONS; + // Copy CB because "function_value" method is non-const. + + octave_value cb = cb_arg; + if (cb.is_function_handle ()) fcn = cb.function_value (); else if (cb.is_string ()) @@ -334,8 +334,10 @@ } static graphics_object -xget_ancestor (graphics_object go, const std::string& type) +xget_ancestor (const graphics_object& go_arg, const std::string& type) { + graphics_object go = go_arg; + do { if (go.valid_object ())