diff gui/src/resource-manager.cc @ 15161:ad9523348676 gui

Make resource_manager a singleton with Octave conventions * resource-manager.cc (resource_manager::instance_ok): New function. * resource-manager.h (resource_manager::instance): Call instance_ok. (resource_manager::instance_ok, resource_manager::cleanup_instance): New functions.
author Mike Miller <mtmiller@ieee.org>
date Sun, 12 Aug 2012 14:36:23 -0400
parents 098546e95a5e
children bc801a44bb1f
line wrap: on
line diff
--- a/gui/src/resource-manager.cc	Sat Aug 11 18:15:29 2012 -0400
+++ b/gui/src/resource-manager.cc	Sun Aug 12 14:36:23 2012 -0400
@@ -25,14 +25,37 @@
 #include <QDir>
 #include <QNetworkProxy>
 
+#include "error.h"
 #include "file-ops.h"
 #include "oct-env.h"
+#include "singleton-cleanup.h"
 
 #include "defaults.h"
 
 #include "resource-manager.h"
 
-resource_manager resource_manager::_singleton;
+resource_manager *resource_manager::_instance = 0;
+
+bool
+resource_manager::instance_ok ()
+{
+  bool retval = true;
+
+  if (! _instance)
+    {
+      _instance = new resource_manager ();
+
+      if (_instance)
+        singleton_cleanup_list::add (cleanup_instance);
+    }
+
+  if (! _instance)
+    {
+      ::error ("unable to create resource_manager object!");
+    }
+
+  return retval;
+}
 
 resource_manager::resource_manager ()
 {