Bug in SBMInteractionModelParticleSystem?
-
I have
- MyInteractionModel which inherits SBMInteractionModelParticleSystem, and
- MyInteractionModelFactory which inherits SBGInteractionModelParticleSystemFactory
In MyInteractionModelFactory, I have a function which overrides the parent class function as follows:
MyInteractionModel * MyInteractionModelFactory ::create(SBParticleSystem* particleSystem) { MyInteractionModel *interactionModel = new MyInteractionModel(particleSystem); interactionModel->initializeInteractions(); if (!interactionModel->setupOK) { delete interactionModel; return NULL; } return interactionModel; }I had a crash at 'delete interactionModel;'
When debugging, I got "Access violation reading ...." exception. And the final break point is at the end of the destructor of MyInteractionModel. The destructor of MyInteractionModel is empty, i.e.
MyInteractionModel ::~MyInteractionModel () { }It seems there is an attempt to delete a memory location which had not been allocated inside one of the parent classes of **MyInteractionModel **.
At the top of my stack, i see SBCReference. Perhaps, it is where the error comes from.
-
Can you please try with a SAMSON pointer (
SBPointer) and let me know how it goes?Normally, any node that is a reference target (i.e. that directly or indrectly derives from
SBCReferenceTarget) should be pointed at with a SAMSON pointer, and deleted with thedeleteReferenceTargetfunction (cf this page).It should thus be:
MyInteractionModel * MyInteractionModelFactory::create(SBParticleSystem* particleSystem) { SBPointer<SBNode> interactionModel = new MyInteractionModel(particleSystem); interactionModel->initializeInteractions(); if (!interactionModel->setupOK) { interactionModel.deleteReferenceTarget(); return NULL; } return interactionModel(); } -
Can you please try with a SAMSON pointer (
SBPointer) and let me know how it goes?Normally, any node that is a reference target (i.e. that directly or indrectly derives from
SBCReferenceTarget) should be pointed at with a SAMSON pointer, and deleted with thedeleteReferenceTargetfunction (cf this page).It should thus be:
MyInteractionModel * MyInteractionModelFactory::create(SBParticleSystem* particleSystem) { SBPointer<SBNode> interactionModel = new MyInteractionModel(particleSystem); interactionModel->initializeInteractions(); if (!interactionModel->setupOK) { interactionModel.deleteReferenceTarget(); return NULL; } return interactionModel(); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login