Merge pull request #12001 from hyperlogic/bug-fix/anim-skeleton-crash

Fix for crash in AnimSkeleton::getNumJoints()
This commit is contained in:
Sam Gondelman 2017-12-15 17:40:42 -08:00 committed by GitHub
commit dab4b12a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -1641,9 +1641,17 @@ void Rig::initAnimGraph(const QUrl& url) {
// load the anim graph
_animLoader.reset(new AnimNodeLoader(url));
_animLoading = true;
connect(_animLoader.get(), &AnimNodeLoader::success, [this](AnimNode::Pointer nodeIn) {
std::weak_ptr<AnimSkeleton> weakSkeletonPtr = _animSkeleton;
connect(_animLoader.get(), &AnimNodeLoader::success, [this, weakSkeletonPtr](AnimNode::Pointer nodeIn) {
_animNode = nodeIn;
_animNode->setSkeleton(_animSkeleton);
// abort load if the previous skeleton was deleted.
auto sharedSkeletonPtr = weakSkeletonPtr.lock();
if (!sharedSkeletonPtr) {
return;
}
_animNode->setSkeleton(sharedSkeletonPtr);
if (_userAnimState.clipNodeEnum != UserAnimState::None) {
// restore the user animation we had before reset.
@ -1651,6 +1659,7 @@ void Rig::initAnimGraph(const QUrl& url) {
_userAnimState = { UserAnimState::None, "", 30.0f, false, 0.0f, 0.0f };
overrideAnimation(origState.url, origState.fps, origState.loop, origState.firstFrame, origState.lastFrame);
}
// restore the role animations we had before reset.
for (auto& roleAnimState : _roleAnimStates) {
auto roleState = roleAnimState.second;

View file

@ -31,7 +31,7 @@ class AnimInverseKinematics;
// Rig instances are reentrant.
// However only specific methods thread-safe. Noted below.
class Rig : public QObject, public std::enable_shared_from_this<Rig> {
class Rig : public QObject {
Q_OBJECT
public:
struct StateHandler {