mirror of https://github.com/fltk/fltk
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:
parent
1b548ae1d5
commit
5c7ef30341
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue