Running FLTK in static initializers (cont'd):

To make sure that fl_graphics_driver is initialized, it is enough to test whether it is null.
This saves the memory cost of a static variable.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10971 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-12-16 10:22:13 +00:00
parent 1b548ae1d5
commit 5c7ef30341
1 changed files with 3 additions and 4 deletions

View File

@ -141,10 +141,9 @@ Fl_Widget::Fl_Widget(int X, int Y, int W, int H, const char* L) {
parent_ = 0;
if (Fl_Group::current()) Fl_Group::current()->add(this);
static int been_here = 0;
if (!been_here) {
been_here = 1;
Fl_Display_Device::display_device(); // make sure fl_graphics_driver is initialized
if (!fl_graphics_driver) {
// Make sure fl_graphics_driver is initialized. Important if we are called by a static initializer.
Fl_Display_Device::display_device();
}
}