diff options
| author | Manolo Gouy <Manolo> | 2015-12-13 06:55:30 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2015-12-13 06:55:30 +0000 |
| commit | 6a608d4862162420db427453d74e70508f6b593f (patch) | |
| tree | 38fe195691be843a8a9d061e9451b761a152e30a | |
| parent | fe92bbed66e8cffeb5e1d329284693763029a829 (diff) | |
Restore the possibility to construct FLTK objects and draw them within static initializers
(which run before main() begins in an uncontrolled order). This was failing because
calls to drawing functions (e.g., fl_font(f,s);) crashed due to uninitialized fl_graphics_driver
global variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10959 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_Widget.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 3982055b9..74287640b 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -141,6 +141,11 @@ 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 + } } void Fl_Widget::resize(int X, int Y, int W, int H) { |
