# HG changeset patch # User John W. Eaton # Date 1323033465 18000 # Node ID e1f76bfe0452a6a9f789ca1a209e5cfb4616cf66 # Parent 051a8f94b6f8419ecbf7efa22c3a06b766125c1c 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. diff -r 051a8f94b6f8 -r e1f76bfe0452 src/graphics.cc --- a/src/graphics.cc Sun Dec 04 15:57:58 2011 -0500 +++ b/src/graphics.cc Sun Dec 04 16:17:45 2011 -0500 @@ -36,10 +36,12 @@ #include #include +#include "cmd-edit.h" #include "file-ops.h" #include "file-stat.h" - -#include "cmd-edit.h" +#include "oct-locbuf.h" +#include "singleton-cleanup.h" + #include "cutils.h" #include "defun.h" #include "display.h" @@ -47,7 +49,6 @@ #include "graphics.h" #include "input.h" #include "ov.h" -#include "oct-locbuf.h" #include "oct-obj.h" #include "oct-map.h" #include "ov-fcn-handle.h" @@ -7395,6 +7396,14 @@ graphics_toolkit::default_toolkit (); } +void +gh_manager::create_instance (void) +{ + instance = new gh_manager (); + + singleton_cleanup_list::add (cleanup_instance); +} + graphics_handle gh_manager::do_make_graphics_handle (const std::string& go_name, const graphics_handle& p, diff -r 051a8f94b6f8 -r e1f76bfe0452 src/graphics.h.in --- a/src/graphics.h.in Sun Dec 04 15:57:58 2011 -0500 +++ b/src/graphics.h.in Sun Dec 04 16:17:45 2011 -0500 @@ -5170,12 +5170,14 @@ public: + static void create_instance (void); + static bool instance_ok (void) { bool retval = true; if (! instance) - instance = new gh_manager (); + create_instance (); if (! instance) { @@ -5187,6 +5189,8 @@ return retval; } + static void cleanup_instance (void) { delete instance; instance = 0; } + static graphics_handle get_handle (bool integer_figure_handle) { return instance_ok () diff -r 051a8f94b6f8 -r e1f76bfe0452 src/oct-errno.cc.in --- a/src/oct-errno.cc.in Sun Dec 04 15:57:58 2011 -0500 +++ b/src/oct-errno.cc.in Sun Dec 04 16:17:45 2011 -0500 @@ -27,6 +27,8 @@ #include +#include "singleton-cleanup.h" + #include "oct-errno.h" #include "oct-map.h" #include "error.h" @@ -292,7 +294,12 @@ bool retval = true; if (! instance) - instance = new octave_errno (); + { + instance = new octave_errno (); + + if (instance) + singleton_cleanup_list::add (cleanup_instance); + } if (! instance) { diff -r 051a8f94b6f8 -r e1f76bfe0452 src/oct-errno.h --- a/src/oct-errno.h Sun Dec 04 15:57:58 2011 -0500 +++ b/src/oct-errno.h Sun Dec 04 16:17:45 2011 -0500 @@ -43,6 +43,8 @@ static bool instance_ok (void); + static void cleanup_instance (void) { delete instance; instance = 0; } + static int lookup (const std::string& name); static octave_scalar_map list (void); diff -r 051a8f94b6f8 -r e1f76bfe0452 src/txt-eng-ft.cc --- 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 +#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 ()