]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.cxx
Canvas: update for new bounding box getters.
[flightgear.git] / src / Main / globals.cxx
1 // globals.cxx -- Global state that needs to be shared among the sim modules
2 //
3 // Written by Curtis Olson, started July 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26
27 #include <boost/foreach.hpp>
28 #include <algorithm>
29
30 #include <osgViewer/Viewer>
31 #include <osgDB/Registry>
32
33 #include <simgear/structure/commands.hxx>
34 #include <simgear/misc/sg_path.hxx>
35 #include <simgear/misc/sg_dir.hxx>
36 #include <simgear/timing/sg_time.hxx>
37 #include <simgear/ephemeris/ephemeris.hxx>
38 #include <simgear/scene/material/matlib.hxx>
39 #include <simgear/structure/subsystem_mgr.hxx>
40 #include <simgear/structure/event_mgr.hxx>
41 #include <simgear/sound/soundmgr_openal.hxx>
42 #include <simgear/misc/ResourceManager.hxx>
43 #include <simgear/props/propertyObject.hxx>
44 #include <simgear/props/props_io.hxx>
45 #include <simgear/scene/model/modellib.hxx>
46
47 #include <Aircraft/controls.hxx>
48 #include <Airports/runways.hxx>
49 #include <Autopilot/route_mgr.hxx>
50 #include <GUI/FGFontCache.hxx>
51 #include <GUI/gui.h>
52 #include <MultiPlayer/multiplaymgr.hxx>
53 #include <Scenery/scenery.hxx>
54 #include <Scenery/tilemgr.hxx>
55 #include <Navaids/navlist.hxx>
56 #include <Viewer/renderer.hxx>
57 #include <Viewer/viewmgr.hxx>
58 #include <Sound/sample_queue.hxx>
59
60 #include "globals.hxx"
61 #include "locale.hxx"
62
63 #include "fg_props.hxx"
64 #include "fg_io.hxx"
65
66 class AircraftResourceProvider : public simgear::ResourceProvider
67 {
68 public:
69   AircraftResourceProvider() :
70     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
71   {
72   }
73   
74   virtual SGPath resolve(const std::string& aResource, SGPath&) const
75   {
76     string_list pieces(sgPathBranchSplit(aResource));
77     if ((pieces.size() < 3) || (pieces.front() != "Aircraft")) {
78       return SGPath(); // not an Aircraft path
79     }
80     
81   // test against the aircraft-dir property
82     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
83     string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
84     if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) {
85         // current aircraft-dir matches resource aircraft
86         SGPath r(aircraftDir);
87         for (unsigned int i=2; i<pieces.size(); ++i) {
88           r.append(pieces[i]);
89         }
90         
91         if (r.exists()) {
92           return r;
93         }
94     }
95   
96   // try each aircraft dir in turn
97     std::string res(aResource, 9); // resource path with 'Aircraft/' removed
98     const string_list& dirs(globals->get_aircraft_paths());
99     string_list::const_iterator it = dirs.begin();
100     for (; it != dirs.end(); ++it) {
101       SGPath p(*it, res);
102       if (p.exists()) {
103         return p;
104       }
105     } // of aircraft path iteration
106     
107     return SGPath(); // not found
108   }
109 };
110
111 class CurrentAircraftDirProvider : public simgear::ResourceProvider
112 {
113 public:
114   CurrentAircraftDirProvider() :
115     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
116   {
117   }
118   
119   virtual SGPath resolve(const std::string& aResource, SGPath&) const
120   {
121     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
122     SGPath p(aircraftDir);
123     p.append(aResource);
124     return p.exists() ? p : SGPath();
125   }
126 };
127
128 ////////////////////////////////////////////////////////////////////////
129 // Implementation of FGGlobals.
130 ////////////////////////////////////////////////////////////////////////
131
132 // global global :-)
133 FGGlobals *globals = NULL;
134
135
136 // Constructor
137 FGGlobals::FGGlobals() :
138     renderer( new FGRenderer ),
139     subsystem_mgr( new SGSubsystemMgr ),
140     event_mgr( new SGEventMgr ),
141     sim_time_sec( 0.0 ),
142     fg_root( "" ),
143     fg_home( "" ),
144     time_params( NULL ),
145     ephem( NULL ),
146     route_mgr( NULL ),
147     controls( NULL ),
148     viewmgr( NULL ),
149     commands( SGCommandMgr::instance() ),
150     channel_options_list( NULL ),
151     initial_waypoints( NULL ),
152     fontcache ( new FGFontCache ),
153     channellist( NULL ),
154     haveUserSettings(false),
155     _chatter_queue(NULL)
156 {
157     SGPropertyNode* root = new SGPropertyNode;
158     props = SGPropertyNode_ptr(root);
159     locale = new FGLocale(props);
160     
161     simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider);
162     simgear::ResourceManager::instance()->addProvider(new CurrentAircraftDirProvider);
163     initProperties();
164 }
165
166 void FGGlobals::initProperties()
167 {
168     simgear::PropertyObjectBase::setDefaultRoot(props);
169     
170     positionLon = props->getNode("position/longitude-deg", true);
171     positionLat = props->getNode("position/latitude-deg", true);
172     positionAlt = props->getNode("position/altitude-ft", true);
173     
174     viewLon = props->getNode("sim/current-view/viewer-lon-deg", true);
175     viewLat = props->getNode("sim/current-view/viewer-lat-deg", true);
176     viewAlt = props->getNode("sim/current-view/viewer-elev-ft", true);
177     
178     orientPitch = props->getNode("orientation/pitch-deg", true);
179     orientHeading = props->getNode("orientation/heading-deg", true);
180     orientRoll = props->getNode("orientation/roll-deg", true);
181
182 }
183
184 // Destructor
185 FGGlobals::~FGGlobals() 
186 {
187     // save user settings (unless already saved)
188     saveUserSettings();
189
190     // The AIModels manager performs a number of actions upon
191     // Shutdown that implicitly assume that other subsystems
192     // are still operational (Due to the dynamic allocation and
193     // deallocation of AIModel objects. To ensure we can safely
194     // shut down all subsystems, make sure we take down the 
195     // AIModels system first.
196     SGSubsystemRef ai = subsystem_mgr->get_subsystem("ai-model");
197     if (ai) {
198         subsystem_mgr->remove("ai-model");
199         ai->unbind();
200         ai.clear(); // ensure AI is deleted now, not at end of this method
201     }
202     
203     subsystem_mgr->shutdown();
204     subsystem_mgr->unbind();    
205
206     subsystem_mgr->remove("aircraft-model");
207     subsystem_mgr->remove("tile-manager");
208     subsystem_mgr->remove("model-manager");
209     _tile_mgr.clear();
210
211     osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());
212     if (vw) {
213         // https://code.google.com/p/flightgear-bugs/issues/detail?id=1291
214         // explicitly stop trheading before we delete the renderer or
215         // viewMgr (which ultimately holds refs to the CameraGroup, and
216         // GraphicsContext)
217         vw->stopThreading();
218     }
219     
220     // don't cancel the pager until after shutdown, since AIModels (and
221     // potentially others) can queue delete requests on the pager.
222     if (vw && vw->getDatabasePager()) {
223         vw->getDatabasePager()->cancel();
224         vw->getDatabasePager()->clear();
225     }
226     
227     osgDB::Registry::instance()->clearObjectCache();
228     
229     // renderer touches subsystems during its destruction
230     set_renderer(NULL);
231     _scenery.clear();
232     _chatter_queue.clear();
233     
234     delete subsystem_mgr;
235     subsystem_mgr = NULL; // important so ::get_subsystem returns NULL
236     vw = 0; // don't delete the viewer until now
237
238     delete time_params;
239     set_matlib(NULL);
240     delete route_mgr;
241     delete channel_options_list;
242     delete initial_waypoints;
243     delete fontcache;
244     delete channellist;
245
246     simgear::PropertyObjectBase::setDefaultRoot(NULL);
247     simgear::SGModelLib::resetPropertyRoot();
248     
249     delete locale;
250     locale = NULL;
251     
252     cleanupListeners();
253     
254     props.clear();
255     
256     delete commands;
257 }
258
259 // set the fg_root path
260 void FGGlobals::set_fg_root (const std::string &root) {
261     SGPath tmp(root);
262     fg_root = tmp.realpath();
263
264     // append /data to root if it exists
265     tmp.append( "data" );
266     tmp.append( "version" );
267     if ( tmp.exists() ) {
268         fgGetNode("BAD_FG_ROOT", true)->setStringValue(fg_root);
269         fg_root += "/data";
270         fgGetNode("GOOD_FG_ROOT", true)->setStringValue(fg_root);
271         SG_LOG(SG_GENERAL, SG_ALERT, "***\n***\n*** Warning: changing bad FG_ROOT/--fg-root to '"
272                 << fg_root << "'\n***\n***");
273     }
274
275     // remove /sim/fg-root before writing to prevent hijacking
276     SGPropertyNode *n = fgGetNode("/sim", true);
277     n->removeChild("fg-root", 0);
278     n = n->getChild("fg-root", 0, true);
279     n->setStringValue(fg_root.c_str());
280     n->setAttribute(SGPropertyNode::WRITE, false);
281     
282     simgear::ResourceManager::instance()->addBasePath(fg_root, 
283       simgear::ResourceManager::PRIORITY_DEFAULT);
284 }
285
286 // set the fg_home path
287 void FGGlobals::set_fg_home (const std::string &home) {
288     SGPath tmp(home);
289     fg_home = tmp.realpath();
290 }
291
292 PathList FGGlobals::get_data_paths() const
293 {
294     PathList r(additional_data_paths);
295     r.push_back(SGPath(fg_root));
296     return r;
297 }
298
299 PathList FGGlobals::get_data_paths(const std::string& suffix) const
300 {
301     PathList r;
302     BOOST_FOREACH(SGPath p, get_data_paths()) {
303         p.append(suffix);
304         if (p.exists()) {
305             r.push_back(p);
306         }
307     }
308
309     return r;
310 }
311
312 void FGGlobals::append_data_path(const SGPath& path)
313 {
314     if (!path.exists()) {
315         SG_LOG(SG_GENERAL, SG_WARN, "adding non-existant data path:" << path);
316     }
317     
318     additional_data_paths.push_back(path);
319 }
320
321 SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const
322 {
323     BOOST_FOREACH(SGPath p, additional_data_paths) {
324         p.append(pathSuffix);
325         if (p.exists()) {
326             return p;
327         }
328     }
329     
330     SGPath rootPath(fg_root);
331     rootPath.append(pathSuffix);
332     if (rootPath.exists()) {
333         return rootPath;
334     }
335     
336     SG_LOG(SG_GENERAL, SG_WARN, "dir not found in any data path:" << pathSuffix);
337     return SGPath();
338 }
339
340 void FGGlobals::append_fg_scenery (const std::string &paths)
341 {
342     SGPropertyNode* sim = fgGetNode("/sim", true);
343
344   // find first unused fg-scenery property in /sim
345     int propIndex = 0;
346     while (sim->getChild("fg-scenery", propIndex) != NULL) {
347       ++propIndex; 
348     }
349   
350     BOOST_FOREACH(const SGPath& path, sgPathSplit( paths )) {
351         SGPath abspath(path.realpath());
352         if (!abspath.exists()) {
353           SG_LOG(SG_GENERAL, SG_WARN, "scenery path not found:" << abspath.str());
354           continue;
355         }
356
357       // check for duplicates
358       string_list::const_iterator ex = std::find(fg_scenery.begin(), fg_scenery.end(), abspath.str());
359       if (ex != fg_scenery.end()) {
360         SG_LOG(SG_GENERAL, SG_INFO, "skipping duplicate add of scenery path:" << abspath.str());
361         continue;
362       }
363       
364         simgear::Dir dir(abspath);
365         SGPath terrainDir(dir.file("Terrain"));
366         SGPath objectsDir(dir.file("Objects"));
367         
368       // this code used to add *either* the base dir, OR add the 
369       // Terrain and Objects subdirs, but the conditional logic was commented
370       // out, such that all three dirs are added. Unfortunately there's
371       // no information as to why the change was made.
372         fg_scenery.push_back(abspath.str());
373         
374         if (terrainDir.exists()) {
375           fg_scenery.push_back(terrainDir.str());
376         }
377         
378         if (objectsDir.exists()) {
379           fg_scenery.push_back(objectsDir.str());
380         }
381         
382         // insert a marker for FGTileEntry::load(), so that
383         // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
384         // "B/Terrain", "B/Objects", ""]
385         fg_scenery.push_back("");
386         
387       // make scenery dirs available to Nasal
388         SGPropertyNode* n = sim->getChild("fg-scenery", propIndex++, true);
389         n->setStringValue(abspath.str());
390         n->setAttribute(SGPropertyNode::WRITE, false);
391         
392         // temporary fix so these values survive reset
393         n->setAttribute(SGPropertyNode::PRESERVE, true);
394     } // of path list iteration
395 }
396
397 void FGGlobals::clear_fg_scenery()
398 {
399   fg_scenery.clear();
400 }
401
402 void FGGlobals::append_aircraft_path(const std::string& path)
403 {
404   SGPath dirPath(path);
405   if (!dirPath.exists()) {
406     SG_LOG(SG_GENERAL, SG_ALERT, "aircraft path not found:" << path);
407     return;
408   }
409     
410   SGPath acSubdir(dirPath);
411   acSubdir.append("Aircraft");
412   if (acSubdir.exists()) {
413       SG_LOG(SG_GENERAL, SG_WARN, "Specified an aircraft-dir with an 'Aircraft' subdirectory:" << dirPath
414                  << ", will instead use child directory:" << acSubdir);
415       dirPath = acSubdir;
416   }
417     
418   std::string abspath = dirPath.realpath();
419   unsigned int index = fg_aircraft_dirs.size();  
420   fg_aircraft_dirs.push_back(abspath);
421   
422 // make aircraft dirs available to Nasal
423   SGPropertyNode* sim = fgGetNode("/sim", true);
424   sim->removeChild("fg-aircraft", index);
425   SGPropertyNode* n = sim->getChild("fg-aircraft", index, true);
426   n->setStringValue(abspath);
427   n->setAttribute(SGPropertyNode::WRITE, false);
428 }
429
430 void FGGlobals::append_aircraft_paths(const std::string& path)
431 {
432   string_list paths = sgPathSplit(path);
433   for (unsigned int p = 0; p<paths.size(); ++p) {
434     append_aircraft_path(paths[p]);
435   }
436 }
437
438 SGPath FGGlobals::resolve_aircraft_path(const std::string& branch) const
439 {
440   return simgear::ResourceManager::instance()->findPath(branch);
441 }
442
443 SGPath FGGlobals::resolve_maybe_aircraft_path(const std::string& branch) const
444 {
445   return simgear::ResourceManager::instance()->findPath(branch);
446 }
447
448 SGPath FGGlobals::resolve_resource_path(const std::string& branch) const
449 {
450   return simgear::ResourceManager::instance()
451     ->findPath(branch, SGPath(fgGetString("/sim/aircraft-dir")));
452 }
453
454 FGRenderer *
455 FGGlobals::get_renderer () const
456 {
457    return renderer;
458 }
459
460 void FGGlobals::set_renderer(FGRenderer *render)
461 {
462     if (render == renderer) {
463         return;
464     }
465     
466     delete renderer;
467     renderer = render;
468 }
469
470 SGSubsystemMgr *
471 FGGlobals::get_subsystem_mgr () const
472 {
473     return subsystem_mgr;
474 }
475
476 SGSubsystem *
477 FGGlobals::get_subsystem (const char * name)
478 {
479     if (!subsystem_mgr) {
480         return NULL;
481     }
482     
483     return subsystem_mgr->get_subsystem(name);
484 }
485
486 void
487 FGGlobals::add_subsystem (const char * name,
488                           SGSubsystem * subsystem,
489                           SGSubsystemMgr::GroupType type,
490                           double min_time_sec)
491 {
492     subsystem_mgr->add(name, subsystem, type, min_time_sec);
493 }
494
495 SGSoundMgr *
496 FGGlobals::get_soundmgr () const
497 {
498     if (subsystem_mgr)
499         return (SGSoundMgr*) subsystem_mgr->get_subsystem("sound");
500
501     return NULL;
502 }
503
504 SGEventMgr *
505 FGGlobals::get_event_mgr () const
506 {
507     return event_mgr;
508 }
509
510 SGGeod
511 FGGlobals::get_aircraft_position() const
512 {
513   return SGGeod::fromDegFt(positionLon->getDoubleValue(),
514                            positionLat->getDoubleValue(),
515                            positionAlt->getDoubleValue());
516 }
517
518 SGVec3d
519 FGGlobals::get_aircraft_position_cart() const
520 {
521     return SGVec3d::fromGeod(get_aircraft_position());
522 }
523
524 void FGGlobals::get_aircraft_orientation(double& heading, double& pitch, double& roll)
525 {
526   heading = orientHeading->getDoubleValue();
527   pitch = orientPitch->getDoubleValue();
528   roll = orientRoll->getDoubleValue();
529 }
530
531 SGGeod
532 FGGlobals::get_view_position() const
533 {
534   return SGGeod::fromDegFt(viewLon->getDoubleValue(),
535                            viewLat->getDoubleValue(),
536                            viewAlt->getDoubleValue());
537 }
538
539 SGVec3d
540 FGGlobals::get_view_position_cart() const
541 {
542   return SGVec3d::fromGeod(get_view_position());
543 }
544
545 static void treeDumpRefCounts(int depth, SGPropertyNode* nd)
546 {
547     for (int i=0; i<nd->nChildren(); ++i) {
548         SGPropertyNode* cp = nd->getChild(i);
549         if (SGReferenced::count(cp) > 1) {
550             SG_LOG(SG_GENERAL, SG_INFO, "\t" << cp->getPath() << " refcount:" << SGReferenced::count(cp));
551         }
552         
553         treeDumpRefCounts(depth + 1, cp);
554     }
555 }
556
557 static void treeClearAliases(SGPropertyNode* nd)
558 {
559     if (nd->isAlias()) {
560         nd->unalias();
561     }
562     
563     for (int i=0; i<nd->nChildren(); ++i) {
564         SGPropertyNode* cp = nd->getChild(i);
565         treeClearAliases(cp);
566     }
567 }
568
569 void
570 FGGlobals::resetPropertyRoot()
571 {
572     delete locale;
573     
574     cleanupListeners();
575     
576     // we don't strictly need to clear these (they will be reset when we
577     // initProperties again), but trying to reduce false-positives when dumping
578     // ref-counts.
579     positionLon.clear();
580     positionLat.clear();
581     positionAlt.clear();
582     viewLon.clear();
583     viewLat.clear();
584     viewAlt.clear();
585     orientPitch.clear();
586     orientHeading.clear();
587     orientRoll.clear();
588     
589     // clear aliases so ref-counts are accurate when dumped
590     treeClearAliases(props);
591     
592     SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs());
593     treeDumpRefCounts(0, props);
594
595     //BaseStackSnapshot::dumpAll(std::cout);
596     
597     props = new SGPropertyNode;
598     initProperties();
599     locale = new FGLocale(props);
600     
601     // remove /sim/fg-root before writing to prevent hijacking
602     SGPropertyNode *n = props->getNode("/sim", true);
603     n->removeChild("fg-root", 0);
604     n = n->getChild("fg-root", 0, true);
605     n->setStringValue(fg_root.c_str());
606     n->setAttribute(SGPropertyNode::WRITE, false);
607 }
608
609 static std::string autosaveName()
610 {
611     std::ostringstream os;
612     string_list versionParts = simgear::strutils::split(VERSION, ".");
613     if (versionParts.size() < 2) {
614         return "autosave.xml";
615     }
616     
617     os << "autosave_" << versionParts[0] << "_" << versionParts[1] << ".xml";
618     return os.str();
619 }
620
621 // Load user settings from autosave.xml
622 void
623 FGGlobals::loadUserSettings(const SGPath& dataPath)
624 {
625     // remember that we have (tried) to load any existing autsave.xml
626     haveUserSettings = true;
627
628     SGPath autosaveFile = simgear::Dir(dataPath).file(autosaveName());
629     SGPropertyNode autosave;
630     if (autosaveFile.exists()) {
631       SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
632       try {
633           readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
634       } catch (sg_exception& e) {
635           SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
636             << "(from " << e.getOrigin() << ")");
637       }
638     }
639     copyProperties(&autosave, globals->get_props());
640 }
641
642 // Save user settings in autosave.xml
643 void
644 FGGlobals::saveUserSettings()
645 {
646     // only save settings when we have (tried) to load the previous
647     // settings (otherwise user data was lost)
648     if (!haveUserSettings)
649         return;
650
651     if (fgGetBool("/sim/startup/save-on-exit")) {
652       // don't save settings more than once on shutdown
653       haveUserSettings = false;
654
655       SGPath autosaveFile(globals->get_fg_home());
656       autosaveFile.append(autosaveName());
657       autosaveFile.create_dir( 0700 );
658       SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
659       try {
660         writeProperties(autosaveFile.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
661       } catch (const sg_exception &e) {
662         guiErrorMessage("Error writing autosave:", e);
663       }
664       SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
665     }
666 }
667
668 FGViewer *
669 FGGlobals::get_current_view () const
670 {
671   return viewmgr->get_current_view();
672 }
673
674 long int FGGlobals::get_warp() const
675 {
676   return fgGetInt("/sim/time/warp");
677 }
678
679 void FGGlobals::set_warp( long int w )
680 {
681   fgSetInt("/sim/time/warp", w);
682 }
683
684 long int FGGlobals::get_warp_delta() const
685 {
686   return fgGetInt("/sim/time/warp-delta");
687 }
688
689 void FGGlobals::set_warp_delta( long int d )
690 {
691   fgSetInt("/sim/time/warp-delta", d);
692 }
693
694 FGScenery* FGGlobals::get_scenery () const
695 {
696     return _scenery.get();
697 }
698
699 void FGGlobals::set_scenery ( FGScenery *s )
700 {
701     _scenery = s;
702 }
703
704 FGTileMgr* FGGlobals::get_tile_mgr () const
705 {
706     return _tile_mgr.get();
707 }
708
709 void FGGlobals::set_tile_mgr ( FGTileMgr *t )
710 {
711     _tile_mgr = t;
712 }
713
714 void FGGlobals::set_matlib( SGMaterialLib *m )
715 {
716     matlib = m;
717 }
718
719 FGSampleQueue* FGGlobals::get_chatter_queue() const
720 {
721     return _chatter_queue;
722 }
723
724 void FGGlobals::set_chatter_queue(FGSampleQueue* queue)
725 {
726     _chatter_queue = queue;
727 }
728
729 void FGGlobals::addListenerToCleanup(SGPropertyChangeListener* l)
730 {
731     _listeners_to_cleanup.push_back(l);
732 }
733
734 void FGGlobals::cleanupListeners()
735 {
736     SGPropertyChangeListenerVec::iterator i = _listeners_to_cleanup.begin();
737     for (; i != _listeners_to_cleanup.end(); ++i) {
738         delete *i;
739     }
740     _listeners_to_cleanup.clear();
741 }
742
743 // end of globals.cxx