bugGNU Octave - Bugs: bug #44116, qt graphics toolkit not available...

 
 

bug #44116: qt graphics toolkit not available with --no-gui option

Submitter:  Stefan Mahr <dac922>
Submitted:  Thu 29 Jan 2015 03:18:41 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 31 May 2015 09:37:44 PM UTC, comment #36: 

I'm closing this bug as fixed, the bug described here has been resolved, agree with comment #33. If there are further improvements that could be made to the interaction between Octave and Qt, that should be a separate bug report or patch tracker item.

Mike Miller <mtmiller>
Group Member
Sun 05 Apr 2015 08:12:13 PM UTC, comment #35: 

The advantage is that it is a more proper way of doing object-oriented programming.  The overall strategy of OOP is sort of ground up, i.e., start with smaller hunks of code and assemble the objects to create complexity.  Passing in the start_gui variable to what is essentially supposed to be Qt window layout means too much functionality is inside that main_window object.  That came about because in the beginning the thought was the GUI was the main end goal.  The building of the link is in the QMainWindow, the construction of dialog-popups is in the QMainWindow, many things are in there that don't need to be.

The reason the uigetfile is hanging is there is no slot connection to the signal requesting a file-dialog be created when QMainWindow (main_window) is not created.  The link sends out a signal and then waits for the answer.  It's straightforward to move the pertinent code out of QMainWindow (main_window) and associate it instead with the octave-qt-link; it's only a few lines of code for each action.

If the Qt environment is going to be set up and working without QMainWindow (first changeset), there's no need for widget/dialog code to be in main-window.cc anymore (second changeset).  In fact, there is this comment in main_window.cc I must have put in some time ago:


// Connect the signals emitted when the Octave thread wants to create
// a dialog box of some sort.  Perhaps a better place for this would be
// as part of the QUIWidgetCreator class.  However, mainWindow currently
// is not a global variable and not accessible for connecting.


Attached is a back-to-back changeset.  You will have to roll back to previous changeset (or extract just the additional changeset from the attached file).  There is always cleanup that can be done, but I simply connected the new slots of QUIWidgetCreator to its own signals.  Seems odd, but that is the least amount of code change.  Also, I'd rather leave it that way for now because I'm anticipating someone will eventually request that the dialogs be non-modal and it seems signals/slots is best for that.

(file #33550)

Dan Sebald <sebald>
Sat 04 Apr 2015 07:11:31 PM UTC, comment #34: 

@Dan: I tried the patch and it applies cleanly, but a simple test of uigetfile failed.  What is the advantage of your patch over the one already committed to Mercurial?

Sample code:


./run-octave -f --no-gui
demo uigetfile
## Hangs here.  Need 3 Ctrl-C to abort.



Rik <rik5>
Group administrator
Sat 04 Apr 2015 06:09:12 PM UTC, comment #33: 

This bug as described in the title has been fixed.
It would be helpful to close this burg report and open a new report about other problems as discussed below.

Michael Godfrey <godfrey>
Group Member
Sat 04 Apr 2015 03:12:25 AM UTC, comment #32: 

I'm attaching a patch that reorganizes things, basically it goes back to the code prior to this change except the construction of the link is moved outside of the QMainWindow construction then its pointer is passed in the main_window::main_window() constructor.  QMainWindow is application window layout and doesn't really need to hold the octave_qt_link.  The only other thing needed is a few extra simple signal/slot connections to supply the shutdown and exit_app functionality.


(file #33527)

Dan Sebald <sebald>
Tue 17 Mar 2015 04:18:06 PM UTC, comment #31: 

I can't judge the implementation as I'm very unfamiliar with the GUI, but works for me.

Carnë Draug <carandraug>
Group Member
Tue 17 Mar 2015 03:56:55 PM UTC, comment #30: 

Patch works for me too.

My suggestion is to deprecate fltk and focus on qt.

Maybe the ui... stuff can be seperated more clearly from the GUI (in terms of configure.ac and directory tree), so that some qt packages can be skiped if the user doesn't need the GUI.

Stefan Mahr <dac922>
Tue 17 Mar 2015 03:45:38 PM UTC, comment #29: 

Probably not, just thought I'd mention it.

Rik <rik5>
Group administrator
Tue 17 Mar 2015 03:37:22 PM UTC, comment #28: 

Given that we have limited resources, I'm wondering whether it is worth the effort to try to handle FLTK and Qt widgets.

John W. Eaton <jwe>
Group administrator
Tue 17 Mar 2015 03:26:05 PM UTC, comment #27: 

The patch works work me.

Not sure if this is important, but now I don't get FLTK windows for uigetfile even when the graphics toolkit is set to fltk.

It's pretty easy to see why as the code assumes qt as long as the octave_link is enabled.


  if (__octave_link_enabled__ ())
    [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:});
  else
    funcname = __get_funcname__ (mfilename ());
    [retfile, retpath, retindex] = feval (funcname, outargs{:});
  endif



Rik <rik5>
Group administrator
Tue 17 Mar 2015 02:17:38 PM UTC, comment #26: 

I checked in the following changeset so that we create a dummy main_window and initialize the octave_link object when running with --no-gui.  With this change, uigetfile seems to work for me and appears to display the Qt widget set.

http://hg.savannah.gnu.org/hgweb/octave/rev/857a8f018f53

John W. Eaton <jwe>
Group administrator
Tue 10 Mar 2015 11:59:39 AM UTC, comment #25: 

Was this patch not planned to also support the ui* functions, like uigetfile and uigetdir? Or are these different? I get the same issue as in comment #18


$ ./run-octave -q --no-gui
octave-gui:1> graphics_toolkit
ans = qt
octave-gui:2> uigetfile
warning: uigetfile: no implementation for toolkit 'qt', using 'fltk' instead
warning: called from
    __get_funcname__ at line 36 column 7
    uigetfile at line 179 column 14
ans = 0
octave-gui:3>  __octave_link_enabled__
ans = 0


Carnë Draug <carandraug>
Group Member
Tue 10 Mar 2015 08:07:17 AM UTC, comment #24: 

'Save As' from menu und the ui... commands doesn't work because of the octave_qt_link stuff. Adding a simple octave_qt_link class to octave_cli_thread helps to get 'Save As' working, but then octave hangs when quit or trying to use ui... commands.


Anonymous
Tue 10 Mar 2015 03:59:19 AM UTC, comment #23: 

Can this bug be closed?  The qt toolkit now works for plotting when Octave is launched with --no-gui.

Rik <rik5>
Group administrator
Mon 02 Mar 2015 02:28:31 PM UTC, comment #22: 

The default qt menu can be removed by

set(gcf, 'MenuBar', 'None')

so it's still possible to build custom menus with uimenu. I think we can forget about the uimenu patch. The octave_link thing still remains an issue.

Stefan Mahr <dac922>
Fri 27 Feb 2015 05:47:54 PM UTC, comment #21: 

Second improved patch.

(file #33202)

Stefan Mahr <dac922>
Fri 27 Feb 2015 05:01:30 PM UTC, comment #20: 

I will try to help with the octave_link thing.

Could you just remove the obsolete code instead of commenting it?

John W. Eaton <jwe>
Group administrator
Fri 27 Feb 2015 04:27:33 PM UTC, comment #19: 

Sorry, I mean printing.

Attached a first patch to replace qt menus with uimenu entries. It reverts patch 7335cc071ab0 and adds uimenu instead.

The 'about' menu and window get lost for now, but should be easy to add. Translation and icons may be more difficult.

The file dialog is currently opened with fltk, since the qt windows need octave_link, but I did not understand the octave_link thing yet.

(file #33200)

Stefan Mahr <dac922>
Fri 27 Feb 2015 04:19:39 PM UTC, comment #18: 

Michael, I wonder why plotting works for you.

Does following command return 0 for you?


octave:2> __octave_link_enabled__
ans = 0


Could you also try command 'uigetfile' ?


octave:1> uigetfile
warning: uigetfile: no implementation for toolkit 'qt', using 'fltk' instead
warning: called from
    __get_funcname__ at line 36 column 7
    uigetfile at line 179 column 14

ans = 0


It opens the fltk window in my case.

Stefan Mahr <dac922>
Fri 27 Feb 2015 04:08:45 PM UTC, comment #17: 

Works just fine for me.
plots seem to match fltk.

Michael Godfrey <godfrey>
Group Member
Fri 27 Feb 2015 02:46:13 PM UTC, comment #16: 

I checked in the change to enable the qt graphics toolkit in this changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/c7c50030e76c

John W. Eaton <jwe>
Group administrator
Fri 27 Feb 2015 02:40:51 PM UTC, comment #15: 

Stefan,

I don't know why the QtHandles code uses Qt menus/QAction items directly instead of uimenu.  That was part of the code before I started working on it, and I really didn't know how menus were handled in the FLTK code until now.

It does seem like it would be better to share the same menu code for both FLTK and Qt but I don't know how to make that work for the Qt code.

John W. Eaton <jwe>
Group administrator
Thu 26 Feb 2015 10:45:56 PM UTC, comment #14: 

Just tried save of plot from plot menu and
quit while plot open.

Both work for me!  Fedora 21.

Thanks!

Michael Godfrey <godfrey>
Group Member
Wed 25 Feb 2015 06:10:36 PM UTC, comment #13: 

John,

just looking to the 'Save' issue. Why using

fileMenu->addAction (tr ("Save &As"))->setEnabled (false);

to generate the menus and not

uimenu (__f, "label", "&Save", "callback", @save_cb);

like in _add_default_menu_.m for fltk?


With current qt implementation it's not possible to overwrite or delete the default menu.


However, I still have no clue why save is not working. Maybe something with 'octave_link'.

Stefan Mahr <dac922>
Wed 25 Feb 2015 05:49:59 PM UTC, comment #12: 

Could you try the following change to scripts/startup/__finish__.m?

Add


close ("all");


to that function.

John W. Eaton <jwe>
Group administrator
Wed 25 Feb 2015 02:11:06 AM UTC, comment #11: 

here is bt from seg fault if quit while plot is open

(gdb) bt
#0  0x00007ffff5531175 in QApplication::x11ProcessEvent(_XEvent*) () from /lib64/libQtGui.so.4
#1  0x00007ffff5558fb4 in x11EventSourceDispatch(_GSource*, int (*)(void*), void*) ()
   from /lib64/libQtGui.so.4
#2  0x00007fffeb585aeb in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#3  0x00007fffeb585e88 in g_main_context_iterate.isra () from /lib64/libglib-2.0.so.0
#4  0x00007fffeb585f3c in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#5  0x00007ffff4fb4a1e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#6  0x00007ffff5559136 in QGuiEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtGui.so.4
#7  0x00007ffff4f84261 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /lib64/libQtCore.so.4
#8  0x00007ffff4f845c5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /lib64/libQtCore.so.4
#9  0x00007ffff4f89ca9 in QCoreApplication::exec() () from /lib64/libQtCore.so.4
#10 0x00007ffff7ab1891 in octave_start_gui (argc=2, argv=0x7fffffffddc8,
    start_gui=<optimized out>) at src/octave-gui.cc:200
#11 0x00007fffecf3cfe0 in __libc_start_main () from /lib64/libc.so.6
#12 0x0000000000400b9f in _start ()
(gdb)


Michael Godfrey <godfrey>
Group Member
Tue 24 Feb 2015 06:32:42 PM UTC, comment #10: 

I don't see a segfault when quit.

Need to look at the Save as issue.

Stefan Mahr <dac922>
Tue 24 Feb 2015 06:16:07 PM UTC, comment #9: 

Stefasn: Did you try save of a plot from
the plot menu? Or try quit while plot is open?

Michael Godfrey <godfrey>
Group Member
Tue 24 Feb 2015 06:13:41 PM UTC, comment #8: 

My builds based on b59aabc08e63 and df3f1d2328d7 works with simple plot(1:4) and quit. Tested with and without --no-gui option.

Stefan Mahr <dac922>
Tue 24 Feb 2015 05:59:14 PM UTC, comment #7: 

Minor problem with the qt patch:
Quitting Octave with a qt plot open results in:
panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-workspace'...
Segmentation fault (core dumped)

Michael Godfrey <godfrey>
Group Member
Sun 22 Feb 2015 06:36:25 AM UTC, comment #6: 

"Sure, but there's a difference between
octave --no-gui
and
octave-cli "

OK, I did not know that.  Thought they were the same.

Dan Sebald <sebald>
Sun 22 Feb 2015 05:52:48 AM UTC, comment #5: 

I tried the patch. Seems to work OK for:
plot(1:100)
print xxx.pdf

works as expected. But, using the save (as)
menu item in the Figure seems to do nothing.
Is this expected?

Do you know of any possible problem side-effects of this
patch? Or, should it be pushed?


Michael Godfrey <godfrey>
Group Member
Sun 22 Feb 2015 12:23:32 AM UTC, comment #4: 

Fine with me. I always use --no-gui
in the appropriate .octaverc files.

Thanks for the clarification.

Michael Godfrey <godfrey>
Group Member
Sat 21 Feb 2015 11:22:59 PM UTC, comment #3: 

Sure, but there's a difference between
octave --no-gui
and
octave-cli

While 'octave-cli' is linked without QT libs - so no qt toolkit available - 'octave --no-gui' is linked with qt. With attached patch 'octave-cli' still uses fltk and 'octave --no-gui' uses qt.

Stefan Mahr <dac922>
Sat 21 Feb 2015 06:06:04 PM UTC, comment #2: 

I assume that Qt graphics toolkit uses the Qt environment to place windows as opposed to an outboard driver.  With CLI no Qt environment exists.  (Octave is a subprocess in the Qt environment when run as a GUI...only the main Qt process can run graphics.)

I'm pretty sure this is the case because the file _init_qt_.cc appears in the libgui subdirectory.  (The function _init_XYZ_() is evaluated inside "graphics_toolkit()".)  It's the file libgui/graphics/__init_qt__.cc if you'd like to look more closely.

Dan Sebald <sebald>
Thu 19 Feb 2015 10:03:31 PM UTC, comment #1: 

Has anyone tested this?  Could it be a candidate
for release 4.0?

It does seem useful and it would reduce the
differences between GUI and CLI use. And, in
any case, having qt plotting available in CLI
would be helpful.

It seems to me a bit odd that all the changes
appear to be in GUI code. Does anything need
to be done in CLI code?

Michael Godfrey <godfrey>
Group Member
Thu 29 Jan 2015 03:18:41 PM UTC, original submission:  

qt graphics toolkit is not initialized when starting with --no-gui option. Attached a quick and dirty fix.

Stefan Mahr <dac922>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #33550:  octave-qt_without_gui-djs2015apr05.patch added by sebald (42KiB - application/octet-stream)
file #33527:  octave-qt_without_gui-djs2015apr03.patch added by sebald (25KiB - application/octet-stream)
file #33202:  qt_uimenu2.diff added by dac922 (8KiB - text/x-patch - version 2)
file #33200:  qt_uimenu.diff added by dac922 (5KiB - text/x-patch - qt menus using uimenu)
file #32939:  qthandles_cmdline.diff added by dac922 (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by dac922 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-05-31 mtmiller StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-04-05 sebald Attached File- Added octave-qt_without_gui-djs2015apr05.patch, #33550
    2015-04-04 sebald Attached File- Added octave-qt_without_gui-djs2015apr03.patch, #33527
    2015-03-17 jwe StatusNone Ready For Test
    2015-02-27 dac922 Attached File- Added qt_uimenu2.diff, #33202
    2015-02-27 dac922 Attached File- Added qt_uimenu.diff, #33200
    2015-01-29 dac922 Attached File- Added qthandles_cmdline.diff, #32939

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code