Resolved? Bug? Cannot unlink namespace parent linkage!
by Daniel Buckmaster · in Torque Game Engine · 11/17/2009 (7:40 pm) · 5 replies
I've done some searching on this error, and everyone seems to indicate that it's caused when you delete an object that's named the same as its namespace:
Anyway, I've written my own custom objects in C++, derived from ScriptObject, and I'm getting the error when I delete them:
datablock PlayerData(PlayerBody)
{
className = PlayerBody;
};I think. That example may be faulty.Anyway, I've written my own custom objects in C++, derived from ScriptObject, and I'm getting the error when I delete them:
Quote:Error, cannot unlink namespace parent linkage for BehaviourTree for ScriptObjectHere's a sample of creating one:
new BehaviourTree(KraftyKorkBehaviourTree)
{
superClass = "BehaviourTree";
};As far as I can tell that's all well and good. I have to set the superClass, otherwise the object will think it's a ScriptObject and I won't be able to define methods like KraftyKorkBehaviourTree::create, and call them as KraftyKorkBehaviourTree.create()About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
11/21/2009 (4:42 am)
Maybe it's just me, but this seems to be an improvement on ScriptObject::onRemove()void ScriptObject::onRemove()
{
// We call this on this objects namespace so we unlink them after. - jdd
//
// Call onRemove in script!
Con::executef(this, 2, "onRemove", Con::getIntArg(getId()));
// Restore NameSpace's
StringTableEntry child = getName();
if( child && child[0] )
{
if(mClassName && mClassName[0])
{
if(Con::unlinkNamespaces(mClassName, child))
child = mClassName;
}
if(mSuperClassName && mSuperClassName[0])
{
if(Con::unlinkNamespaces(mSuperClassName, child))
child = mSuperClassName;
}
Con::unlinkNamespaces("ScriptObject",child);
}
else
{
child = mClassName;
if(child && child[0])
{
if(mSuperClassName && mSuperClassName[0])
{
if(Con::unlinkNamespaces(mSuperClassName, child))
child = mSuperClassName;
}
Con::unlinkNamespaces("ScriptObject",child);
}
else
{
if(mSuperClassName && mSuperClassName[0])
Con::unlinkNamespaces("ScriptObject",mSuperClassName);
}
}
Parent::onRemove();
}In all those cases unlinking "ScriptObject", getClassname was previously being used, which didn't seem to be returning the intended result. Anyone have a better idea of whether my changes make sense and are safe?
#3
Can't quite remember what I did to resolve the issue.
11/21/2009 (1:42 pm)
I've actually run across this problem multiple times before as well, though I don't think I actually had any problems with it, but I also have not done too much using custom or advanced gui functions.Can't quite remember what I did to resolve the issue.
#4
11/21/2009 (5:53 pm)
From what I could see in searches, it had to do with naming objects the same as their class. That would certainly cause an error, because there'd be two different namespaces, but identically named, and trying to unlink them would have the engine think you're unlinking a class from itself.
#5
I think thats how I fixed the problems before... either I renamed it or deleted and made a fresh object.
11/21/2009 (7:22 pm)
Thats strange because I've never named an object the same as the class, though the editors have been known to rename things as they wish.I think thats how I fixed the problems before... either I renamed it or deleted and made a fresh object.
Torque Owner Daniel Buckmaster
T3D Steering Committee
I was incorrect to write superClass = "BehaviourTree"... I think that should have just been class = "BehaviourTree".
Linking works fine for me - the process is straight-forward, see ScriptObject::onAdd. If I create a BehaviourTree, the link goes ObjectName->BehaviourTree->ScriptObject->SimObject just like it should. However, when it comes to unlink, this happens:
// Restore NameSpace's StringTableEntry child = getName(); if( child && child[0] ) { if(mClassName && mClassName[0]) { if(Con::unlinkNamespaces(mClassName, child)) child = mClassName; } if(mSuperClassName && mSuperClassName[0]) { if(Con::unlinkNamespaces(mSuperClassName, child)) child = mSuperClassName; } Con::unlinkNamespaces(getClassName(),child); }mClassName is "BehaviourTree", so we first unlink ObjectName from BehaviourTree (all well and good), and child = "BehaviourTree".No super class name to worry about.
Then we get to the bottom line which confuses me. It tries to unlink BehaviourTree from itself, since getClassName returns BehaviourTree. Which seems to make sense. Should I be setting mSuperClassName (to... "ScriptObject"?)? But then that way I'd be trying to unlink ScriptObject (child) from BehaviourTree (parent).