1
0
Fork 0

fix a segmentation fault situation that is exposed at least on IRIX (but not Linux).

This commit is contained in:
ehofman 2004-09-22 10:03:26 +00:00
parent 26e6b0edcb
commit 9d1b5164e2
2 changed files with 9 additions and 7 deletions

View file

@ -287,15 +287,11 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) {
void FGAIManager::processScenario( string filename ) { void FGAIManager::processScenario( string filename ) {
FGAIScenario* s = new FGAIScenario( filename ); FGAIScenario* s = new FGAIScenario( filename );
for (int i=0;i<s->nEntries();i++) { for (int i=0;i<s->nEntries();i++) {
FGAIModelEntity* en = s->getNextEntry(); FGAIModelEntity* en = s->getNextEntry();
if (en) { if (en) {
en->fp = NULL;
if (en->flightplan != ""){
en->fp = new FGAIFlightPlan( en->flightplan );
}
if (en->m_class == "aircraft") { if (en->m_class == "aircraft") {
createAircraft( en ); createAircraft( en );

View file

@ -30,6 +30,7 @@
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include "AIScenario.hxx" #include "AIScenario.hxx"
#include "AIFlightPlan.hxx"
@ -49,6 +50,7 @@ FGAIScenario::FGAIScenario(string filename)
return; return;
} }
entries.clear();
SGPropertyNode * node = root.getNode("scenario"); SGPropertyNode * node = root.getNode("scenario");
for (i = 0; i < node->nChildren(); i++) { for (i = 0; i < node->nChildren(); i++) {
//cout << "Reading entry " << i << endl; //cout << "Reading entry " << i << endl;
@ -80,7 +82,11 @@ FGAIScenario::FGAIScenario(string filename)
en->wind = entry_node->getBoolValue("wind", false); en->wind = entry_node->getBoolValue("wind", false);
en->cd = entry_node->getDoubleValue ("cd", 0.029); en->cd = entry_node->getDoubleValue ("cd", 0.029);
en->weight = entry_node->getDoubleValue ("weight", 0.030); en->weight = entry_node->getDoubleValue ("weight", 0.030);
en->fp = NULL; en->fp = NULL;
if (en->flightplan != ""){
en->fp = new FGAIFlightPlan( en->flightplan );
}
} }
entry_iterator = entries.begin(); entry_iterator = entries.begin();