Mercurial > hg > octave-terminal
changeset 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 | 051a8f94b6f8 |
children | e58963b5c0b1 |
files | src/graphics.cc src/graphics.h.in src/oct-errno.cc.in src/oct-errno.h src/txt-eng-ft.cc |
diffstat | 5 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -36,10 +36,12 @@ #include <string> #include <sstream> +#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,
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -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 ()
--- a/src/oct-errno.cc.in +++ b/src/oct-errno.cc.in @@ -27,6 +27,8 @@ #include <cerrno> +#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) {
--- a/src/oct-errno.h +++ b/src/oct-errno.h @@ -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);
--- a/src/txt-eng-ft.cc +++ b/src/txt-eng-ft.cc @@ -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 ()