Bugfix: Missing parent object causes assert in ReplicationComponent::Stop

Fixes #3601
This commit is contained in:
Gunnar Beutner 2013-02-01 11:46:52 +01:00
parent b8fa0aa1f5
commit e928b1fabf
1 changed files with 8 additions and 4 deletions

View File

@ -267,11 +267,13 @@ void DynamicObject::Register(void)
{ {
assert(Application::IsMainThread()); assert(Application::IsMainThread());
DynamicObject::Ptr dobj = GetType()->GetObject(GetName()); DynamicType::Ptr dtype = GetType();
DynamicObject::Ptr dobj = dtype->GetObject(GetName());
DynamicObject::Ptr self = GetSelf(); DynamicObject::Ptr self = GetSelf();
assert(!dobj || dobj == self); assert(!dobj || dobj == self);
GetType()->RegisterObject(self); dtype->RegisterObject(self);
OnRegistered(GetSelf()); OnRegistered(GetSelf());
@ -287,10 +289,12 @@ void DynamicObject::Unregister(void)
{ {
assert(Application::IsMainThread()); assert(Application::IsMainThread());
if (!GetType()->GetObject(GetName())) DynamicType::Ptr dtype = GetType();
if (!dtype || !dtype->GetObject(GetName()))
return; return;
GetType()->UnregisterObject(GetSelf()); dtype->UnregisterObject(GetSelf());
OnUnregistered(GetSelf()); OnUnregistered(GetSelf());
} }