| 6989 | } |
| 6990 | |
| 6991 | XN_C_API XnStatus xnScriptNodeRun(XnNodeHandle hScript, XnEnumerationErrors* pErrors) |
| 6992 | { |
| 6993 | XnStatus nRetVal = XN_STATUS_OK; |
| 6994 | |
| 6995 | XN_VALIDATE_INTERFACE_TYPE(hScript, XN_NODE_TYPE_SCRIPT); |
| 6996 | |
| 6997 | XnNodeInfoList* pCreatedNodes = NULL; |
| 6998 | nRetVal = xnNodeInfoListAllocate(&pCreatedNodes); |
| 6999 | XN_IS_STATUS_OK(nRetVal); |
| 7000 | |
| 7001 | XnEnumerationErrors* pActualErrors = pErrors; |
| 7002 | if (pActualErrors == NULL) |
| 7003 | { |
| 7004 | nRetVal = xnEnumerationErrorsAllocate(&pActualErrors); |
| 7005 | if (nRetVal != XN_STATUS_OK) |
| 7006 | { |
| 7007 | xnNodeInfoListFree(pCreatedNodes); |
| 7008 | return (nRetVal); |
| 7009 | } |
| 7010 | } |
| 7011 | |
| 7012 | // run the script |
| 7013 | nRetVal = xnScriptNodeRunImpl(hScript, pCreatedNodes, pActualErrors); |
| 7014 | |
| 7015 | if (nRetVal == XN_STATUS_OK) |
| 7016 | { |
| 7017 | // add all created nodes to the list of dependencies |
| 7018 | for (XnNodeInfoListIterator it = xnNodeInfoListGetFirst(pCreatedNodes); |
| 7019 | xnNodeInfoListIteratorIsValid(it); |
| 7020 | it = xnNodeInfoListGetNext(it)) |
| 7021 | { |
| 7022 | XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it); |
| 7023 | if (pInfo->hNode == NULL) |
| 7024 | { |
| 7025 | nRetVal = XN_STATUS_ERROR; |
| 7026 | break; |
| 7027 | } |
| 7028 | |
| 7029 | nRetVal = xnAddNeededNode(hScript, pInfo->hNode); |
| 7030 | if (nRetVal != XN_STATUS_OK) |
| 7031 | { |
| 7032 | break; |
| 7033 | } |
| 7034 | } |
| 7035 | } |
| 7036 | |
| 7037 | // release all nodes (either we had an error, or they are already added to the list of needed nodes |
| 7038 | for (XnNodeInfoListIterator it = xnNodeInfoListGetFirst(pCreatedNodes); |
| 7039 | xnNodeInfoListIteratorIsValid(it); |
| 7040 | it = xnNodeInfoListGetNext(it)) |
| 7041 | { |
| 7042 | XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it); |
| 7043 | if (pInfo->hNode != NULL) |
| 7044 | { |
| 7045 | xnProductionNodeRelease(pInfo->hNode); |
| 7046 | } |
| 7047 | } |
| 7048 |
no test coverage detected