Metar: add safe string storage for tied property
This commit is contained in:
parent
138a678a30
commit
b6e4cbbf14
2 changed files with 9 additions and 2 deletions
|
@ -204,8 +204,9 @@ static const double thickness_value[] = { 0, 65, 600, 750, 1000 };
|
|||
|
||||
const char* MetarProperties::get_metar() const
|
||||
{
|
||||
if (!_metar) return "";
|
||||
return _metar->getRawDataPtr();
|
||||
if (!_metar || _metarData.empty())
|
||||
return "";
|
||||
return _metarData.c_str();
|
||||
}
|
||||
|
||||
void MetarProperties::set_metar( const char * metarString )
|
||||
|
@ -239,9 +240,13 @@ void MetarProperties::setMetar( SGSharedPtr<FGMetar> m )
|
|||
_metar = m;
|
||||
_decoded.clear();
|
||||
if (!m) {
|
||||
_metarData.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// copy the string so we have guranteed storage for get_metar tied property API
|
||||
_metarData = _metar->getDataString();
|
||||
|
||||
const vector<string> weather = m->getWeather();
|
||||
for( vector<string>::const_iterator it = weather.begin(); it != weather.end(); ++it ) {
|
||||
if( !_decoded.empty() ) _decoded.append(", ");
|
||||
|
|
|
@ -69,6 +69,8 @@ private:
|
|||
SGPropertyNode_ptr _rootNode;
|
||||
SGPropertyNode_ptr _metarValidNode;
|
||||
|
||||
std::string _metarData;
|
||||
|
||||
std::string _station_id;
|
||||
double _station_elevation;
|
||||
double _station_latitude;
|
||||
|
|
Loading…
Add table
Reference in a new issue