diff --git a/simgear/structure/subsystem_mgr.cxx b/simgear/structure/subsystem_mgr.cxx index f9eb752b..5e26a432 100644 --- a/simgear/structure/subsystem_mgr.cxx +++ b/simgear/structure/subsystem_mgr.cxx @@ -301,8 +301,6 @@ SGSubsystemGroup::set_subsystem (const string &name, SGSubsystem * subsystem, double min_step_sec) { Member * member = get_member(name, true); - if (member->subsystem != 0) - delete member->subsystem; member->name = name; member->subsystem = subsystem; member->min_step_sec = min_step_sec; @@ -430,11 +428,11 @@ SGSubsystemGroup::Member::update (double delta_time_sec) SGSubsystemMgr::SGSubsystemMgr () : + _groups(MAX_GROUPS), _initPosition(0) { - for (int i = 0; i < MAX_GROUPS; i++) { - _groups[i] = new SGSubsystemGroup; - } + for (int i = 0; i < MAX_GROUPS; i++) + _groups[i].reset(new SGSubsystemGroup); } SGSubsystemMgr::~SGSubsystemMgr () @@ -442,10 +440,7 @@ SGSubsystemMgr::~SGSubsystemMgr () // ensure get_subsystem returns NULL from now onwards, // before the SGSubsystemGroup destructors are run _subsystem_map.clear(); - - for (int i = 0; i < MAX_GROUPS; i++) { - delete _groups[i]; - } + _groups.clear(); } void diff --git a/simgear/structure/subsystem_mgr.hxx b/simgear/structure/subsystem_mgr.hxx index caa804e8..4139fa68 100644 --- a/simgear/structure/subsystem_mgr.hxx +++ b/simgear/structure/subsystem_mgr.hxx @@ -345,6 +345,8 @@ private: unsigned int _initPosition; }; +typedef SGSharedPtr SGSubsystemGroupRef; + /** * Manage subsystems for FlightGear. * @@ -413,9 +415,9 @@ public: void setReportTimingCb(void* userData,SGSubsystemTimingCb cb) {reportTimingCb = cb;reportTimingUserData = userData;} private: - SGSubsystemGroup* _groups[MAX_GROUPS]; + std::vector _groups; unsigned int _initPosition; - + // non-owning reference typedef std::map SubsystemDict; SubsystemDict _subsystem_map;