From 6a608d4862162420db427453d74e70508f6b593f Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 13 Dec 2015 06:55:30 +0000 Subject: 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 --- src/Fl_Widget.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Fl_Widget.cxx') 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) { -- cgit v1.2.3