From 5c7ef303413c03a0c5f645276e9c2b7ae8289680 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 16 Dec 2015 10:22:13 +0000 Subject: 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 --- src/Fl_Widget.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Fl_Widget.cxx') 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(); } } -- cgit v1.2.3