Skip to content

Throw error code to be handled by the Gmsh API

Max Orok requested to merge fltk-errors into master

Some Fltk errors will cause the program to abort, without throwing an error that an API code handle.

This might not be an acceptable patch since the Fl::fatal handler is probably expected to kill the program.

This MR is more about trying to make portable API examples that include calls to GUI functions.

For example, WSL doesn't have an X display setup by default so any calls to the fltk functions will abort with:

Info    : Meshing 1D...
Info    : Meshing curve 1 (Line)
Info    : Meshing curve 2 (Line)
Info    : Meshing curve 3 (Line)
Info    : Meshing curve 4 (Line)
Info    : Done meshing 1D (0 s)
Info    : Meshing 2D...
Info    : Meshing surface 1 (Plane, Delaunay)
Info    : Done meshing 2D (0.09375 s)
Info    : Meshing 3D...
Info    : Done meshing 3D (0 s)
Info    : 428 nodes 858 elements
Fatal   : Can't open display: :0 (FLTK internal error)        

Since the SDK is built with FLTK, it isn't caught earlier by HAVE_FLTK defines.

It would be nice to be able to handle fatal FLTK errors yet still continue on if you like, maybe printing an error message instead for demo scripts that can't use the gui.

If nothing else, I'd like to raise this as an issue but understand if the change isn't acceptable.

Thank you very much for your time.

Merge request reports