summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/prefs.cc
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-06-27 15:07:32 -0400
committerTom Rondeau <tom@trondeau.com>2014-06-27 15:07:32 -0400
commit6be4c6fc1190f83764a317ad8185bbd6b4f813ba (patch)
treeb67bb05b2b5aa57548191feaf6ca3d2b71ee4a7f /gnuradio-runtime/lib/prefs.cc
parent9a7222577bc5425b17b513b94e0de73e847bd9da (diff)
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.
Diffstat (limited to 'gnuradio-runtime/lib/prefs.cc')
-rw-r--r--gnuradio-runtime/lib/prefs.cc16
1 files changed, 3 insertions, 13 deletions
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()