diff src/txt-eng-ft.cc @ 13992:e1f76bfe0452

apply singleton_cleanup to a few more classes * ft-manager.cc (ft_manager::cleanup_instance): New function. (ft_manager::instance_ok): Add instance to singleton_cleanup_list. * graphics.h.in, graphics.cc (gh_mananger::create_instance, gh_manager::cleanup_instance): New functions. (gh_manager::instance_ok): Call create_instance. * oct-errno.h (octave_errno::cleanup_instance): New function. * oct-errno.cc.in (octave_errno::instance_ok): Add instance to singleton_cleanup_list.
author John W. Eaton <jwe@octave.org>
date Sun, 04 Dec 2011 16:17:45 -0500
parents a2c74b5c02de
children 1221086f1ba5
line wrap: on
line diff
--- a/src/txt-eng-ft.cc	Sun Dec 04 15:57:58 2011 -0500
+++ b/src/txt-eng-ft.cc	Sun Dec 04 16:17:45 2011 -0500
@@ -32,6 +32,8 @@
 
 #include <iostream>
 
+#include "singleton-cleanup.h"
+
 #include "error.h"
 #include "pr-output.h"
 #include "txt-eng-ft.h"
@@ -72,7 +74,12 @@
       bool retval = true;
 
       if (! instance)
-        instance = new ft_manager ();
+        {
+          instance = new ft_manager ();
+
+          if (instance)
+            singleton_cleanup_list::add (cleanup_instance);
+        }
 
       if (! instance)
         {
@@ -84,6 +91,8 @@
       return retval;
     }
 
+  static void cleanup_instance (void) { delete instance; instance = 0; }
+
   static FT_Face get_font (const std::string& name, const std::string& weight,
                            const std::string& angle, double size)
     { return (instance_ok ()