The error message in debug mode is something to the effect of: expression map/set iterator not incrementable.
The problem is caused by ofxKinectContext::closeAll looping over the ofxKinect map and calling ofxKinect::close() which triggers ofxKinectContext::close which finally erases the iterator from the map. The map.erase() is the heart of the problem because this invalidates the map iterators causing ofxKinectContext::closeAll to access an out of range iterator.
One solution to this problem which does not involve refactoring how closeAll and close work is to simply make a temporary copy of the map in closeAll and then loop over this temporary map calling close on each device. This avoids the invalid iterators and should be safe because only ofxKinect::close is being called. Also since this is only done on shutdown and the kinect map will never be large I don't see this solution as a large performance impact.
The closeAll snippet for the solution described above:
The error message in debug mode is something to the effect of: expression map/set iterator not incrementable.
The problem is caused by ofxKinectContext::closeAll looping over the ofxKinect map and calling ofxKinect::close() which triggers ofxKinectContext::close which finally erases the iterator from the map. The map.erase() is the heart of the problem because this invalidates the map iterators causing ofxKinectContext::closeAll to access an out of range iterator.
One solution to this problem which does not involve refactoring how closeAll and close work is to simply make a temporary copy of the map in closeAll and then loop over this temporary map calling close on each device. This avoids the invalid iterators and should be safe because only ofxKinect::close is being called. Also since this is only done on shutdown and the kinect map will never be large I don't see this solution as a large performance impact.
The closeAll snippet for the solution described above: