From 7019fcdc15c20d5aea2f87587621d2117a890b5d Mon Sep 17 00:00:00 2001 From: daveluff Date: Sun, 11 Apr 2004 15:20:36 +0000 Subject: [PATCH] Fix a seg fault that could be caused if all no AI models were in existance. Ssg could then free the memory pointed to by our pointer behind our back, causing it to crash when next approaching a controlled airport requiring an AI model. Fix is to hold one ref to each model in the AIMgr at all times. --- src/ATC/AIMgr.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ATC/AIMgr.cxx b/src/ATC/AIMgr.cxx index 8f23a5507..5a9d3f6d3 100644 --- a/src/ATC/AIMgr.cxx +++ b/src/ATC/AIMgr.cxx @@ -56,6 +56,8 @@ FGAIMgr::FGAIMgr() { } FGAIMgr::~FGAIMgr() { + _defaultModel->deRef(); + _piperModel->deRef(); } void FGAIMgr::init() { @@ -84,6 +86,10 @@ void FGAIMgr::init() { globals->get_props(), globals->get_sim_time_sec() ); + // We need to keep one ref of the models open to stop ssg deleting them behind our back! + _defaultModel->ref(); + _piperModel->ref(); + // go through the $FG_ROOT/ATC directory and find all *.taxi files SGPath path(globals->get_fg_root()); path.append("ATC/"); -- 2.39.5