]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/menubar.cxx
Make sure that all elapsed time gets passed to update when a subsystem
[flightgear.git] / src / GUI / menubar.cxx
index 38de42f5832daaa0560699ca1347b058ffaa8ed5..7a41fb8a7e37fea769b8e35765b9e2daad378b2c 100644 (file)
@@ -58,15 +58,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
 }
 #endif // TR_HIRES_SNAP
 
-extern void dumpSnapShot (puObject *);
-static bool
-do_snapshot_dialog (const SGPropertyNode * arg)
-{
-    dumpSnapShot(0);
-    return true;
-}
-
-
 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
 extern void printScreen (puObject *);
 static bool
@@ -101,78 +92,6 @@ do_properties_dialog (const SGPropertyNode * arg)
     return true;
 }
 
-extern void fgPresetAirport (puObject *);
-static bool
-do_preset_airport_dialog (const SGPropertyNode * arg)
-{
-    fgPresetAirport(0);
-    return true;
-}
-
-extern void fgPresetRunway (puObject *);
-static bool
-do_preset_runway_dialog (const SGPropertyNode * arg)
-{
-    fgPresetRunway(0);
-    return true;
-}
-
-extern void fgPresetOffsetDistance (puObject *);
-static bool
-do_preset_offset_distance_dialog (const SGPropertyNode * arg)
-{
-    fgPresetOffsetDistance(0);
-    return true;
-}
-
-extern void fgPresetAltitude (puObject *);
-static bool
-do_preset_altitude_dialog (const SGPropertyNode * arg)
-{
-    fgPresetAltitude(0);
-    return true;
-}
-
-extern void fgPresetGlideslope (puObject *);
-static bool
-do_preset_glideslope_dialog (const SGPropertyNode * arg)
-{
-    fgPresetGlideslope(0);
-    return true;
-}
-
-extern void fgPresetAirspeed (puObject *);
-static bool
-do_preset_airspeed_dialog (const SGPropertyNode * arg)
-{
-    fgPresetAirspeed(0);
-    return true;
-}
-
-extern void fgPresetCommit (puObject *);
-static bool
-do_preset_commit_dialog (const SGPropertyNode * arg)
-{
-    fgPresetCommit(0);
-    return true;
-}
-
-extern void NewAltitude (puObject *);
-static bool
-do_ap_altitude_dialog (const SGPropertyNode * arg)
-{
-    NewAltitude(0);
-    return true;
-}
-
-extern void NewHeading (puObject *);
-static bool
-do_ap_heading_dialog (const SGPropertyNode * arg)
-{
-    NewHeading(0);
-    return true;
-}
-
 extern void AddWayPoint (puObject *);
 static bool
 do_ap_add_waypoint_dialog (const SGPropertyNode * arg)
@@ -227,26 +146,16 @@ static struct {
 } deprecated_dialogs [] = {
     { "old-save-dialog", do_save_dialog },
     { "old-load-dialog", do_load_dialog },
-    { "old-reinit_dialog", do_reinit_dialog },
+    { "old-reinit-dialog", do_reinit_dialog },
 #if defined(TR_HIRES_SNAP)
     { "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
 #endif
-    { "old-snapshot-dialog", do_snapshot_dialog },
 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
     { "old-print-dialog", do_print_dialog },
 #endif
     { "old-pilot-offset-dialog", do_pilot_offset_dialog },
     { "old-hud-alpha-dialog", do_hud_alpha_dialog },
     { "old-properties-dialog", do_properties_dialog },
-    { "old-preset-airport-dialog", do_preset_airport_dialog },
-    { "old-preset-runway-dialog", do_preset_runway_dialog },
-    { "old-preset-offset-distance-dialog", do_preset_offset_distance_dialog },
-    { "old-preset-altitude-dialog", do_preset_altitude_dialog },
-    { "old-preset-glideslope-dialog", do_preset_glideslope_dialog },
-    { "old-preset-airspeed-dialog", do_preset_airspeed_dialog },
-    { "old-preset-commit-dialog", do_preset_commit_dialog },
-    { "old-ap-altitude-dialog", do_ap_altitude_dialog },
-    { "old-ap-heading-dialog", do_ap_heading_dialog },
     { "old-ap-add-waypoint-dialog", do_ap_add_waypoint_dialog },
     { "old-ap-pop-waypoint-dialog", do_ap_pop_waypoint_dialog },
     { "old-ap-clear-route-dialog", do_ap_clear_route_dialog },
@@ -297,15 +206,38 @@ FGMenuBar::FGMenuBar ()
 FGMenuBar::~FGMenuBar ()
 {
     hide();
-    delete _menuBar;            // FIXME: check if PUI owns the pointer
+    puDeleteObject(_menuBar);
+
+    int i;
+
+                                // 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
+        delete _char_arrays[i];
+    }
+
+                                // 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<string,vector<FGBinding *> >::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
@@ -342,26 +274,27 @@ FGMenuBar::isVisible () const
     return _visible;
 }
 
-bool
+void
 FGMenuBar::fireItem (puObject * item)
 {
     const char * name = item->getLegend();
     vector<FGBinding *> &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();
 }
 
 void
-FGMenuBar::make_menu (SGPropertyNode_ptr node)
+FGMenuBar::make_menu (SGPropertyNode * node)
 {
     const char * name = strdup(node->getStringValue("label"));
     vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");
 
-    int array_size = item_nodes.size() + 1;
+    int array_size = item_nodes.size();
 
-    char ** items = new char*[array_size];
-    puCallback * callbacks = new puCallback[array_size];
+    char ** items = make_char_array(array_size);
+    puCallback * callbacks = make_callback_array(array_size);
 
     for (int i = 0, j = item_nodes.size() - 1;
          i < item_nodes.size();
@@ -374,13 +307,11 @@ FGMenuBar::make_menu (SGPropertyNode_ptr node)
                                 // Load all the bindings for this item
         vector<SGPropertyNode_ptr> binding_nodes =
             item_nodes[i]->getChildren("binding");
+
         for (int k = 0; k < binding_nodes.size(); k++)
             _bindings[items[j]].push_back(new FGBinding(binding_nodes[k]));
     }
 
-    items[item_nodes.size()] = 0;
-    callbacks[item_nodes.size()] = 0;
-
     _menuBar->add_submenu(name, items, callbacks);
 }
 
@@ -402,4 +333,24 @@ FGMenuBar::make_menubar ()
         _menuBar->hide();
 }
 
+char **
+FGMenuBar::make_char_array (int size)
+{
+    char ** list = new char*[size+1];
+    for (int i = 0; i <= size; i++)
+        list[i] = 0;
+    _char_arrays.push_back(list);
+    return list;
+}
+
+puCallback *
+FGMenuBar::make_callback_array (int size)
+{
+    puCallback * list = new puCallback[size+1];
+    for (int i = 0; i <= size; i++)
+        list[i] = 0;
+    _callback_arrays.push_back(list);
+    return list;
+}
+
 // end of menubar.cxx