Make PUI menu-bar reinit safe.
Was only cleaning up the PUI menubar, not old bindings / names. This led to duplicate bindings, each time the GUI was reset, which can happen for various reasons.
This commit is contained in:
parent
d886f2a5f8
commit
04598859e3
1 changed files with 7 additions and 4 deletions
|
@ -95,8 +95,7 @@ FGPUIMenuBar::~FGPUIMenuBar ()
|
||||||
void
|
void
|
||||||
FGPUIMenuBar::init ()
|
FGPUIMenuBar::init ()
|
||||||
{
|
{
|
||||||
delete _menuBar; // FIXME: check if PUI owns the pointer
|
destroy_menubar();
|
||||||
_menuBar = NULL;
|
|
||||||
|
|
||||||
make_menubar();
|
make_menubar();
|
||||||
// FIXME: temporary commands to get at
|
// FIXME: temporary commands to get at
|
||||||
|
@ -178,7 +177,7 @@ FGPUIMenuBar::make_menu (SGPropertyNode * node)
|
||||||
// Load all the bindings for this item
|
// Load all the bindings for this item
|
||||||
vector<SGPropertyNode_ptr> bindings = item_nodes[i]->getChildren("binding");
|
vector<SGPropertyNode_ptr> bindings = item_nodes[i]->getChildren("binding");
|
||||||
SGPropertyNode * dest = fgGetNode("/sim/bindings/menu", true);
|
SGPropertyNode * dest = fgGetNode("/sim/bindings/menu", true);
|
||||||
|
|
||||||
for (unsigned int k = 0; k < bindings.size(); k++) {
|
for (unsigned int k = 0; k < bindings.size(); k++) {
|
||||||
unsigned int m = 0;
|
unsigned int m = 0;
|
||||||
SGPropertyNode_ptr binding;
|
SGPropertyNode_ptr binding;
|
||||||
|
@ -269,7 +268,7 @@ FGPUIMenuBar::destroy_menubar ()
|
||||||
delete[] _char_arrays[i];
|
delete[] _char_arrays[i];
|
||||||
_char_arrays[i] = 0;
|
_char_arrays[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all the callback arrays
|
// Delete all the callback arrays
|
||||||
// we were forced to keep around for
|
// we were forced to keep around for
|
||||||
// plib.
|
// plib.
|
||||||
|
@ -286,6 +285,10 @@ FGPUIMenuBar::destroy_menubar ()
|
||||||
delete it->second[i];
|
delete it->second[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_menuBar = NULL;
|
||||||
|
_bindings.clear();
|
||||||
|
_char_arrays.clear();
|
||||||
|
_callback_arrays.clear();
|
||||||
SG_LOG(SG_GENERAL, SG_BULK, "Done.");
|
SG_LOG(SG_GENERAL, SG_BULK, "Done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue