[BUG] Daz Studio 6 crash when using DzTransferUtility::getTargetOutputFigure()
Using DzTransferUtility::getTargetOutputFigure() method from script crashes Daz Studio 6.
Script to reproduce the crash :
(function(){
var tu = new DzTransferUtility();
tu.getTargetOutputFigure();
})();
Post edited by Mike3D on

Comments
Was theer a target figur0e (a figure selected in the scene)?
Yes, and there's also a source figure, but the Transfer Utility, whether run from script or not, does not require any selection in the scene.
Now, even if the scene is empty, Studio shouldn't crash, the method should simply return null.
The problem seems to be that in DS6 it can crash if there is no valid output figure yet.
A safer approach is to perform the transfer first, then reacquire the resulting figure from the scene instead of calling that getter:
var tu = new DzTransferUtility();
tu.setSource(sourceFigure);
tu.setTarget(targetNode);
if (tu.doTransfer()) {
// Transfer Utility replaces the original target node,
// so find the new live figure again in the scene.
var nodes = Scene.getNodeList();
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].getLabel() === targetLabel) {
var outputFigure = nodes[i];
print("Output figure: " + outputFigure.getLabel());
break;
}
}
}
So instead of relying on:
tu.getTargetOutputFigure();
you can let the transfer complete and then locate the newly created figure in the scene. That's essentially how I've avoided needing that getter.
Many thanks for your solution
Actually we can simply do like that :
Glad it helped :D