From 0940afae5a9c4859efbead88283ae5c317bd7f94 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 21 Jan 2003 02:08:56 +0000 Subject: [PATCH] Fixed iteration bug in destructor. --- src/GUI/menubar.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/GUI/menubar.cxx b/src/GUI/menubar.cxx index 250a6b7fd..0fa6d496d 100644 --- a/src/GUI/menubar.cxx +++ b/src/GUI/menubar.cxx @@ -286,6 +286,7 @@ FGMenuBar::~FGMenuBar () // Delete all the character arrays // we were forced to keep around for // plib. + std::cerr << "Deleting char arrays\n"; for (i = 0; i < _char_arrays.size(); i++) { for (int j = 0; _char_arrays[i][j] != 0; j++) free(_char_arrays[i][j]); // added with strdup @@ -295,16 +296,21 @@ FGMenuBar::~FGMenuBar () // Delete all the callback arrays // we were forced to keep around for // plib. + std::cerr << "Deleting callback arrays\n"; for (i = 0; i < _callback_arrays.size(); i++) delete _callback_arrays[i]; // Delete all those bindings + std::cerr << "Deleting bindings\n"; map >::iterator it; it = _bindings.begin(); - while (it != _bindings.end()) { + for (it = _bindings.begin(); it != _bindings.end(); it++) { + std::cerr << "Deleting bindings for " << it->first << std::endl; for (int i = 0; i < it->second.size(); i++) delete it->second[i]; } + + std::cerr << "Done.\n"; } void @@ -346,8 +352,9 @@ FGMenuBar::fireItem (puObject * item) { const char * name = item->getLegend(); vector &bindings = _bindings[name]; + int nBindings = bindings.size(); - for (int i = 0; i < bindings.size(); i++) + for (int i = 0; i < nBindings; i++) bindings[i]->fire(); }