![]() |
In addition to that, a large change was made in Version 7.0 with the way SOP geometry is stored. This may affect your custom SOP code, especially if you use callback buttons. A summary follows:
const GU_Detail *gdp; gdp = sop->getCookedGeo(context);should be replaced by
GU_~DetailHandleAutoReadLock gdl(sop->getCookedGeoHandle(context)); const GU_Detail *gdp = gdl.getGdp();
GU_Detail *gdp; gdp = (GU_Detail *) sop->getCookedGeo(context);should be replaced by
GU_~DetailHandleAutoWriteLock gdl(sop->getCookedGeoHandle(context)); GU_Detail *gdp = gdl.getGdp();
const GU_Detail *gdp; gdp = (const GU_Detail *) sop->getCookedData(context);should be replaced by
GU_~DetailHandle *handle, gdh; handle = (GU_~DetailHandle *) sop->getCookedData(context); if (handle) gdh = *handle; GU_~DetailHandleAutoReadLock gdl(gdh); const GU_Detail *gdp = gdl.getGdp();
const GU_Detail * getSopGeo(const char *sopname, OP_Context &context) { SOP_Node *node; node = OPgetDirector()->findSOPNode(sopname); if (!node) return 0; return node->getCookedGeo(context); }should be replaced by
GU_~DetailHandle getSopGeoHandle(const char *sopname, OP_Context &context) { SOP_Node *node; node = OPgetDirector()->findSOPNode(sopname); if (!node) return GU_~DetailHandle(); return node->getCookedGeoHandle(context); }The caller of these functions should then do the appropriate locking conventions.
int SOP_Foo::staticCallback(...) { SOP_Foo *me = (SOP_Foo *) data; UT_~AutoUndoBlock undoblock("Foo"); me->callback(...); return 0; }should be replaced by
int SOP_Foo::staticCallback(...) { SOP_Foo *me = (SOP_Foo *) data; UT_~AutoUndoBlock undoblock("Foo"); GU_~DetailHandleAutoWriteLock gdl(me->myGdpHandle); if (gdl.getGdp()) { me->gdp = gdl.getGdp(); me->callback(...); me->gdp = 0; } return 0; }
unlockInput(0); if (inputGeo(0, context)->points().entries() > 3)The problem is that as of the unlockInput call, the input geometry may be freed. This happens aggressively with the [SOPUnloading] being set to Always.
sopnode->expandGroupNames(("*", gnms, 1, pgdp);should be replaced by
{ GU_DetailHandle gdh; gdh = sopnode->getCookedGeoHandle(context); GU_DetailHandleAutoReadLock gdl(gdh); sopnode->expandGroupNames(("*", gnms, 1, (GU_Detail *)gdl.getGdp()); }