diff options
| author | Manolo Gouy <Manolo> | 2015-12-16 10:22:13 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2015-12-16 10:22:13 +0000 |
| commit | 5c7ef303413c03a0c5f645276e9c2b7ae8289680 (patch) | |
| tree | b4691b17ab4bc6d39e1aae98feed1f95cefefc5d /src/Fl_Widget.cxx | |
| parent | 1b548ae1d54ff31faa94bc4fd13b98cf4989c613 (diff) | |
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
Diffstat (limited to 'src/Fl_Widget.cxx')
| -rw-r--r-- | src/Fl_Widget.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 74287640b..5b4cadb19 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -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(); } } |
