Can someone shed some light on why I get a crash in the following test code:
//temp tests
Node* myNode = scene_->CreateChild();
WeakPtr<StaticModel> gridComp = WeakPtr<StaticModel>(myNode->CreateComponent<StaticModel>());URHO3D_LOGINFO(String(gridComp.Refs()));// 1
gridComp->GetNode()->Remove();
URHO3D_LOGINFO(String(gridComp.Refs()));// 0
if (gridComp.NotNull()) {
gridComp->GetNode()->Remove(); //crash here
}
This does print 0 references:
URHO3D_LOGINFO(String(gridComp.Refs()));// 0
But this is returning true:
gridComp.NotNull()
I must be missing something simple. I want to use the gridComp variable as a way of polling whether the staticmodel still exists or not which I thought was the reason to use weakptr.