From 6be4c6fc1190f83764a317ad8185bbd6b4f813ba Mon Sep 17 00:00:00 2001 From: Tom Rondeau <tom@trondeau.com> Date: Fri, 27 Jun 2014 15:07:32 -0400 Subject: runtime: restructure prefs class for initializing prefs singleton. Boost filesystem has a bug initializing a static variable when linking statically. This forces the initialization to happen when the first call to prefs::singleton is made. We should really put the prefs ctor in private, but then swig complains. --- gnuradio-runtime/lib/prefs.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'gnuradio-runtime/lib/prefs.cc') diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc index d03c6777eb..b7fcaada9d 100644 --- a/gnuradio-runtime/lib/prefs.cc +++ b/gnuradio-runtime/lib/prefs.cc @@ -36,22 +36,12 @@ namespace fs = boost::filesystem; namespace gr { - /* - * Stub implementations - */ - static prefs s_default_singleton; - static prefs *s_singleton = &s_default_singleton; - prefs * prefs::singleton() { - return s_singleton; - } - - void - prefs::set_singleton(prefs *p) - { - s_singleton = p; + static prefs instance; // Guaranteed to be destroyed. + // Instantiated on first use. + return &instance; } prefs::prefs() -- cgit v1.2.3