bugGNU Octave - Bugs: bug #50295, Calling feval() from within the Qt...


bug #50295: Calling feval() from within the Qt GUI requires to press enter otherwise the prompt is busy

Submitted by:  Roland Baudin <roland65>
Submitted on:  Mon 13 Feb 2017 04:24:12 PM UTC  
Category: GUISeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: Works For MeAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.2.0Operating System: GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Sun 19 Feb 2017 05:24:43 PM UTC, comment #12:

Ok, you can close the bug.
You're right, this was not the correct way to implement a graphic function.

Roland Baudin <roland65>
Sun 19 Feb 2017 05:19:57 PM UTC, comment #11:

We have already shown here that this is not a general problem. When the function called is "disp", the function actually does complete correctly.

I think this bug should be closed as everything is working correctly. I think you should explore another way to get the box to be drawn on the figure window because that specific code path does not seem to be working, probably because you have the GUI thread calling the interpreter which is trying to call back into the GUI thread. Do you agree?

Mike Miller <mtmiller>
Project Administrator
Sat 18 Feb 2017 08:08:07 AM UTC, comment #10:

>>Pressing Enter in the command window is required to somehow get the tooltip to appear on the figure window

Yes, it's exactly the problem. For some reason, calling a .m from the gui requires the user to type enter otherwise the function does not complete correctly and the prompt is stuck. The example with the disp() function was just to try to simplify the problem.

Roland Baudin <roland65>
Fri 17 Feb 2017 05:38:53 PM UTC, comment #9:

I'm sorry I don't really understand what the data cursor on a plot has to do with what is printed to the command window or whether the user has to press Enter.

As I understand it the data cursor is a tooltip that appears on a figure window when the figure area is clicked. I don't see how that requires any kind of display or interaction on the command window. If it's just for debugging while implementing this function, then I don't see any problem with the current behavior.

If pressing Enter in the command window is required to somehow get the tooltip to appear on the figure window, then that looks like a different problem from just getting the prompt to be redrawn. You may have run into a different problem and assumed that it's for the same reasons as what you describe here, while the example shown here doesn't seem to be a bug at all.

It seems more likely to me that it's because you are calling an m file function that sends a signal to the Qt figure thread to draw a text box. Instead maybe the data cursor should be done entirely in libgui without making such a callback to the interpreter.

Mike Miller <mtmiller>
Project Administrator
Fri 17 Feb 2017 08:14:34 AM UTC, comment #8:

To Mike: the problem for me is point 2. As I said in the previous comment, I intended to add a callback to the datacursor of Pantxo Diribarne, but this doesn't work as expected because the user has to press enter any time he clicks on the menu item, otherwise the data cursor does not appear.

Perhaps, my approach is not the correct one, so if there is some alternative, please tell me...

Roland Baudin <roland65>
Fri 17 Feb 2017 08:11:39 AM UTC, comment #7:

To jwe: yes, same behaviour with your example. OK, I understand this is the correct and expected way.

In fact, my problem is the following. I thought it was simple to add a callback to a function to the figure window menu (the function I was interested in is the datacursor() function written by Pantxo Diribarne, see http://octave.1599824.n4.nabble.com/Data-cursor-in-Octave-td4681801.html).

So I added the menu callback but it doesn't work properly because the user has to press enter in the command window after he has clicked somewhere on the figure to put the datacursor.

Perhaps, there is some method to call to simulate this enter pressing ?

Roland Baudin <roland65>
Fri 17 Feb 2017 12:44:25 AM UTC, comment #6:

Roland - which of the following are you reporting as the bug here:

1. You have to click in the figure window for the text to be printed to the command window, rather than it appearing immediately when the menu item is selected?

2. You have to press Enter in the command window for the Octave prompt to be redrawn?

These are two different behaviors, and I don't think I can reproduce the first one. I agree with jwe that the second behavior is simply how Octave works, it should not be redisplaying the prompt any time any text is printed to the command window out of band with what the user is typing.

Mike Miller <mtmiller>
Project Administrator
Thu 16 Feb 2017 01:33:38 PM UTC, comment #5:

I think the behavior you are seeing is expected. When you write to the command window, Octave doesn't redraw the prompt after your output. Is the behavior the same for you with the following code?

Maybe Octave should redraw the prompt, but I'm not sure exactly when that should happen or what should trigger it. I know, you are probably thinking "after output is displayed in the command window", but how much output? After each callback function is executed, or just after a series of them have been executed and there are no more pending events? How do we know there won't be more events arriving?

John W. Eaton <jwe>
Project Administrator
Thu 16 Feb 2017 10:53:04 AM UTC, comment #4:

OK, I was probably not clear.

Here are the steps to reproduce the issue:

1. Add the code snippet I provided to Figure.cc and add the prototypes of the two functions to Figure.h (myfunction_callback to the private section and myFunction to the private slot section).

2. Rebuild Octave and run it

3. In the command window, type:

4. In the figure window, click on the new menu item Edit / My function

5. Click somewhere in the figure

6. Then the command window displays '1' (the figure number) and the prompt does not return. You'll have to press enter get the prompt again

This is 100 % reproducible.

Roland Baudin <roland65>
Wed 15 Feb 2017 05:42:28 PM UTC, comment #3:

Then I am not able to reproduce this. I do see a delay until pressing Enter in the command window, but only when the pager is enabled.

Mike Miller <mtmiller>
Project Administrator
Wed 15 Feb 2017 07:51:13 AM UTC, comment #2:

I have 'more off' in my .octaverc file, so the problem is not there.

Roland Baudin <roland65>
Tue 14 Feb 2017 11:45:59 PM UTC, comment #1:

Can you confirm that running "more off" in the command window results in the display happening immediately? This appears to me to be an interaction between the default pager buffering mode and the output of the disp function.

If a GUI menu item or other input method wanted to display output on the command window immediately, it might be helpful to look at how it is done in the Workspace panel.

If you can confirm that it is simply the pager mode that is affecting the result, does something need to be done about this or is it working as expected?

Mike Miller <mtmiller>
Project Administrator
Mon 13 Feb 2017 04:24:12 PM UTC, original submission:

I tried to add a new menu item to the figure window of the qt graphics toolkit, to call an Octave function from the figure window.

I used the following code in libgui/graphics/Figure.cc:

Figure::createFigureToolBarAndMenuBar (void)

editMenu->addSeparator ();
editMenu->addActions (m_mouseModeGroup->actions ());
editMenu->addAction (tr ("&My function"), this, SLOT (myFunction (void)));

< ... >

Figure::myFunction (void)
octave_link::post_event (this, &Figure::myfunction_callback);

Figure::myfunction_callback (void)
figure::properties& fp = properties<figure> ();
octave_value fnum = fp.get___myhandle__ ().as_octave_value ();

Ffeval (ovl ("disp", fnum));
//feval (ovl ("fprintf",1,"example\n"), 1);

This silly example should display the figure id in the command window (of course the real function will do much more).

This almost works (to test, plot anything and click on the Edit / My function menu item), but after the figure id is displayed in the command window, the prompt gets stuck and I have to type <enter> to get the prompt back again.

Same behaviour with the fprintf() function (see the commented line above)...

Roland Baudin <roland65>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by roland65 (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 19 Feb 2017 05:35:03 PM UTCmtmillerOpen/ClosedOpen=>Closed
    Wed 15 Feb 2017 05:42:28 PM UTCmtmillerStatusNeed Info=>Works For Me
    Tue 14 Feb 2017 11:45:59 PM UTCmtmillerStatusNone=>Need Info

    Back to the top

    Powered by Savane 3.1-cleanup1