Subsystems: add checks to avoid crash on early exit
Don’t crash if the user exits before subsystems are bound / init-ed
This commit is contained in:
parent
676a2e3880
commit
0a7e6b9b84
@ -340,6 +340,11 @@ SGSubsystemGroup::reinit ()
|
|||||||
void
|
void
|
||||||
SGSubsystemGroup::shutdown ()
|
SGSubsystemGroup::shutdown ()
|
||||||
{
|
{
|
||||||
|
if (_state < State::INIT) {
|
||||||
|
SG_LOG(SG_EVENT, SG_ALERT, "Shutdown of non-init-ed group:" << _name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reverseForEach([this](SGSubsystem* s){
|
reverseForEach([this](SGSubsystem* s){
|
||||||
this->notifyWillChange(s, State::SHUTDOWN);
|
this->notifyWillChange(s, State::SHUTDOWN);
|
||||||
s->shutdown();
|
s->shutdown();
|
||||||
@ -363,6 +368,11 @@ SGSubsystemGroup::bind ()
|
|||||||
void
|
void
|
||||||
SGSubsystemGroup::unbind ()
|
SGSubsystemGroup::unbind ()
|
||||||
{
|
{
|
||||||
|
if (_state < State::BIND) {
|
||||||
|
SG_LOG(SG_EVENT, SG_ALERT, "Unbind of non-bound group:" << _name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reverseForEach([this](SGSubsystem* s){
|
reverseForEach([this](SGSubsystem* s){
|
||||||
this->notifyWillChange(s, State::UNBIND);
|
this->notifyWillChange(s, State::UNBIND);
|
||||||
s->unbind();
|
s->unbind();
|
||||||
|
Loading…
Reference in New Issue
Block a user