Jump to content

Model->Release Crashes


martyj
 Share

Recommended Posts

On my demo map, the game crashes whenever I drop an item. (And only on this map).

 

I am on the Non-Beta branch.

 

Here is the crash I receive: http://imgur.com/a/oVIJL

 

Sample Code:

 

Creation

this->model = (Model*)Model::Load(item->GetModelPath(), Asset::Unmanaged);
this->model->SetUserData(this);
this->model->SetKeyValue("name", item->GetName());
this->model->SetVelocity(Vec3(0, 0, 0), true);
this->model->SetCollisionType(Collision::Prop);
this->model->SetPhysicsMode(Entity::RigidBodyPhysics);
this->model->SetPickMode(Entity::SpherePick, true);
this->model->SetMass(10); // TODO: real mass
this->model->SetSweptCollisionMode(true);
this->model->SetPosition(position, true);

 

Destroy Code

ItemEntity::~ItemEntity()
{
this->model->SetParent(NULL);
this->model->Hide(); // TODO: Delete me
this->model->SetUserData(NULL);
this->model->Release();
}

 

I can provide my full source code if needed.

Link to comment
Share on other sites

That happens to me if I somehow use the model after I release it, even if I'd swear up and down that it's impossible. But if you're saying it doesn't happen on other maps then I'm not sure.

 

Also, not sure if you check elsewhere but you may consider checking if model==NULL (and setting it at the start and after release).

Link to comment
Share on other sites

If you look at the stacktrace on the image, there is no way that I could use it after I release it as the exception is thrown in library code that is above my Release call in the stack. So it's somewhere in Leadwerks code that the crash happens, in the RemoveAll function.

Link to comment
Share on other sites

Well, the Release() method works just fine for me, so I guess the problem is elsewhere.

Before you call the destructor, do you see the item in game? If you're not sure it does, the problem might be the attempt to Hide() an empty model. The error happens when you try to call the destructor or when you exit the map? If it happens when you exit the map, maybe you call delete world before the destructor of ItemEntity.

 

PS: I have no idea what Asset::Unmanaged is.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...