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
This commit is contained in:
Manolo Gouy 2015-12-13 06:55:30 +00:00
parent fe92bbed66
commit 6a608d4862
1 changed files with 5 additions and 0 deletions

View File

@ -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) {