Reset: ensure mobile tacan drop its AI references
Add a slightly ugly hook, to force mobile nav records to drop their refs into the property tree on reset.
This commit is contained in:
parent
51bb8ed5ce
commit
977bfb06bf
5 changed files with 30 additions and 2 deletions
|
@ -1269,7 +1269,10 @@ void fgStartNewReset()
|
|||
// don't delete here, dropping the ref should be sufficient
|
||||
}
|
||||
} // of top-level groups iteration
|
||||
|
||||
|
||||
// drop any references to AI objects with TACAN
|
||||
flightgear::NavDataCache::instance()->clearDynamicPositioneds();
|
||||
|
||||
FGRenderer* render = globals->get_renderer();
|
||||
// needed or we crash in multi-threaded OSG mode
|
||||
render->getViewer()->stopThreading();
|
||||
|
|
|
@ -1725,6 +1725,16 @@ void NavDataCache::abortTransaction()
|
|||
d->transactionAborted = true;
|
||||
}
|
||||
|
||||
void NavDataCache::clearDynamicPositioneds()
|
||||
{
|
||||
std::for_each(d->cache.begin(), d->cache.end(), [](PositionedCache::value_type& v) {
|
||||
if (v.second->type() == FGPositioned::MOBILE_TACAN) {
|
||||
auto mobile = fgpositioned_cast<FGMobileNavRecord>(v.second);
|
||||
mobile->clearVehicle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FGPositionedRef NavDataCache::loadById(PositionedID rowid)
|
||||
{
|
||||
if (rowid < 1) {
|
||||
|
|
|
@ -336,6 +336,9 @@ public:
|
|||
class ThreadedGUISearchPrivate;
|
||||
std::unique_ptr<ThreadedGUISearchPrivate> d;
|
||||
};
|
||||
|
||||
void clearDynamicPositioneds();
|
||||
|
||||
private:
|
||||
NavDataCache();
|
||||
|
||||
|
|
|
@ -166,6 +166,11 @@ const SGVec3d& FGMobileNavRecord::cart() const
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void FGMobileNavRecord::clearVehicle()
|
||||
{
|
||||
_vehicle_node.clear();
|
||||
}
|
||||
|
||||
void FGMobileNavRecord::updateVehicle()
|
||||
{
|
||||
_vehicle_node.clear();
|
||||
|
|
|
@ -126,6 +126,11 @@ class FGMobileNavRecord:
|
|||
public FGNavRecord
|
||||
{
|
||||
public:
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{
|
||||
return (ty == MOBILE_TACAN);
|
||||
}
|
||||
|
||||
FGMobileNavRecord( PositionedID aGuid,
|
||||
Type type,
|
||||
const std::string& ident,
|
||||
|
@ -142,7 +147,9 @@ class FGMobileNavRecord:
|
|||
void updateVehicle();
|
||||
void updatePos();
|
||||
|
||||
protected:
|
||||
void clearVehicle();
|
||||
|
||||
protected:
|
||||
SGTimeStamp _last_vehicle_update;
|
||||
SGPropertyNode_ptr _vehicle_node;
|
||||
double _initial_elevation_ft; // Elevation as given in the config file
|
||||
|
|
Loading…
Add table
Reference in a new issue