|
|
On Saturday, January 21, 2023 at 7:39:31 PM UTC-6 Albrecht Schlosser wrote:
On 1/21/23 21:00 Paul Hahn wrote:
That said, before commit 4b945a308 (Nov 5, 2022) there was an
unwanted initialization of the graphics driver in the constructor of
Fl_Widget (and hence also Fl_Window) which was removed with the
mentioned commit. This was necessary for the hybrid X11/Wayland FLTK
platform on Unix/Linux, but this early initialization of the
graphics driver had been problematic anyway.
This *may* have hidden the problem to access uninitialized font data
in your program because it crashed now with the missing graphics
driver initialization.
Fair enough, but indeed it had been my (unjustified in hindsight) assumption that some kind of "default" was extant after at least instantiating an Fl_Window. By "default", I mean the FLTK obfuscation of so-called typeface font number '0' was at least available, whatever face it is. I will now adjust things in my code as necessary to avoid that assumption.
On the other hand, maybe some other toolkits (Qt?) take
care of this kind of initialization issue in a global
initialization routine that programmers are required to call
at the start? Like as with Fl::lock() in FLTK when we need to
use MT and locks. Or, as it now appears, fl_open_display(),
which might essentially fill that role now in FLTK, so calling
it at the start of their program is what everyone should do as
boilerplate.
fl_open_display() is called internally in many places when needed,
e.g. Fl_Window::show() but also Fl::font(face, size),
Fl::get_system_colors() and some (many) more functions. The rule is
not to call it if it's not needed (as in fluid in command mode `-c`)
but if you're sure your program needs it because it's a GUI program,
then it's not wrong to call it at the start of main(). Our goal is
to open the display only when necessary and that's usually when
Fl_Window::show(...) is called.
Yes that is a reasonable argument. Heretofore I had unthinkingly assumed all FLTK programs are GUI oriented. Thanks for clarifying that for me.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/55fc3b3d-b156-4049-a042-31e2f388a653n%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |