Sat 11 Jun 2016 01:41:02 AM UTC, comment #8:
Oops, I totally misread comment #2 and was thinking the error was the same before and after the callback executed. You had it right to begin with,
http://hg.savannah.gnu.org/hgweb/octave/rev/25b117822bfd
|
Sat 11 Jun 2016 01:27:25 AM UTC, comment #7:
I'm not sure we care to be 100% compatible, but Matlab stores the message "Error while evaluating UIControl Callback" in the lasterror field. Wouldn't it be simpler not to save/restore the lasterror state? Or just leave it alone so it had the error message from inside the callback itself?
|
Sat 11 Jun 2016 12:40:24 AM UTC, comment #6:
Thanks for the idea. I changed this yet a little more by saving and restoring the last error structure to what it was before the callback was called,
http://hg.savannah.gnu.org/hgweb/octave/rev/0331d3e832e3
|
Fri 10 Jun 2016 04:57:01 AM UTC, comment #5:
@Mike: Take a look at my newly uploaded diff. I fake the error message by writing to std::cerr and then set the internal error message by calling the Octave function lasterr().
Feel free to modify the message, or to commit the change.
(file #37442)
|
Thu 09 Jun 2016 06:11:41 PM UTC, comment #4:
Well the attached diff works for me, with both string and function handle callbacks in place. This definitely gets rid of the "parse error" message and only shows the intended callback message. But it still sets lasterror to the message originating in the callback. Some more tweaking will be necessary if it's also important that the global error state is not changed when the callback executes.
(file #37440)
|
Thu 09 Jun 2016 05:30:19 PM UTC, comment #3:
Changing this report to a Feature Request and lowering the Severity and Priority. Octave behaves equivalently to Matlab, except the error message is less informative.
I don't know if it can be fixed, but the place to fix it will be in libinterp/corefcn/graphics.cc. The function in question is gh_manager::do_execute_callback(). If the callback is a string, then eval_string is called, if it is anything else then feval is called.
Interestingly, there are differences between eval_string and feval. The example in comment #0 used a string for the callback. The following code uses a function handle.
Just for grins, I put the feval in do_execute_callback inside a try/catch block.
And running now produces
It works to produce the new error message, but I also get a "parse error" message. This must be coming from the parser itself in parse-tree/oct-parse.cc
|
Thu 09 Jun 2016 10:57:16 AM UTC, comment #2:
Here is what happens with Matlab:
|
Wed 08 Jun 2016 06:43:10 PM UTC, comment #1:
Confirmed here.
What does Matlab's lasterror function show after calling uicontrol but before actually clicking on the button? What does lasterror show after clicking on the button?
|
Wed 08 Jun 2016 12:05:40 PM UTC, original submission:
When an error is thrown during the execution of a uicontrol callback (that does not contain any syntax error), a "parse error" error message is displayed:
It seems slightly misleading. In the same context, Matlab displays "Error while evaluating UIControl Callback".
|