Hey guys,
An char* to string conversion looks to be generating a segfault. I'm pretty sure that's not it, but that's when GDB says it received one...
Well, here's the, what I think, relevant code. If you think more code is relevant I'll post that too of course.
Entity.h (objLocation definition, ctor definition)
public:
entity(char *location, bool loadNow);
(...)
private:
(...)
string objLocation;
};
Entity.cpp (constructor only)
entity::entity(char *modellocation, bool loadNow):
visible(true)
{
for(int i = 0; i < 3; i++){
location[i] = rotation[i] = 0;
}
objLocation = modellocation; //BOOM segfault. :(
if(loadNow){
loadentity();
}
return;
}
World.cpp (createAndAddEntity method, origin of the call to the entity constructor)
void world::createAndAddEntity(char *location, bool loadNow){
entity *holdThis = new entity(location, loadNow);
world::addEntity(holdThis);
return;
}
And too make it just the bit more confusing for me:
main.cpp
scene.createAndAddEntity("C:\\Code\\BowViceJetDeux\\testobj\\anubis.obj", true);
scene.createAndAddEntity("C:\\Code\\BowViceJetDeux\\testobj\\anubis.obj", true);
First works good, second one gives that segfault mentioned earlier. Why does it do that? :(
Thanks in Advance,
Nick