THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/08/2004 at 11:27, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.206
Platform:
Language(s) : C++ ;
---------
Hi,
Ive coded up a quite complex ObjectData plugin and after adding a feature it crashes. I know exactly where the crash occurs, but I don't know how to stop it.
Some background on what is happening with my plugin.
I create a few clones of a child object of the ObjectData object inside GetVirtualObjects.
BaseObject *oBase = op->GetDown();
if(!oBase) return NULL;
// The following happens a few times in a loop
BaseObject *oClone = (BaseObject* )oBase->GetClone();
if(!oClone) return NULL;
I have a struct that I use to create a Link List. The struct is something like
struct mystruct
{
LONG ID;
BaseObject *oReferenceObject;
mystruct *NextNode;
}
The oReferenceObject is pointing to the a clone object that I created earlier by doing this
// If there is already a reference, don't reference it again
if(!mystructlist->oReferenceObject)
mystructlist->oReferenceObject=oClone;
Now all this works fine like it should. My problem is what comes next
in my ObjectData::Draw(...) method, I want to check on some propeties of the clones that I referenced in my LinkList. in Psuedoish Code
ObjectData::Draw(...)
{
mystruct *node=HeadPointer;
LOOPTHROUGHLINKLIST
{
if(node->oRefrenceObject)
{
// THIS IS *ALWAYS* VALID
GePrint(node->oReferenceObject->GetName());
}
}
}
The result of this operation is that the objects name is printed to the console once, then C4D will crash the next time it attempts to print the name. Even though the oReferenceObject is not NULL.
As you can see, its a quite complicated piece of code, but im guessing it crashes because oReferenceObject is pointing to a invalid pointer due to GetVirtualObjects.
I'm just a confirmation thats the case