Always stop challenge timer from the right thread

This commit is contained in:
Clement 2019-09-09 16:01:45 -07:00
parent 3c35433f86
commit 3b734b2222
3 changed files with 13 additions and 1 deletions

View file

@ -499,6 +499,8 @@ void AvatarMixer::handleAvatarKilled(SharedNodePointer avatarNode) {
} else {
_sessionDisplayNames.erase(displayNameIter);
}
nodeData->getAvatar().stopChallengeTimer();
}
std::unique_ptr<NLPacket> killPacket;

View file

@ -332,7 +332,7 @@ void MixerAvatar::sendOwnerChallenge() {
void MixerAvatar::processChallengeResponse(ReceivedMessage& response) {
QByteArray avatarID;
QMutexLocker certifyLocker(&_avatarCertifyLock);
QMetaObject::invokeMethod(&_challengeTimer, &QTimer::stop);
stopChallengeTimer();
if (_verifyState == challengeClient) {
QByteArray responseData = response.readAll();
if (responseData.length() < 8) {
@ -365,3 +365,11 @@ void MixerAvatar::processChallengeResponse(ReceivedMessage& response) {
qCDebug(avatars) << "WARNING: Unexpected avatar challenge-response in state" << stateToName(_verifyState);
}
}
void MixerAvatar::stopChallengeTimer() {
if (QThread::currentThread() == thread()) {
_challengeTimer.stop();
} else {
QMetaObject::invokeMethod(&_challengeTimer, &QTimer::stop);
}
}

View file

@ -34,6 +34,8 @@ public:
void processCertifyEvents();
void processChallengeResponse(ReceivedMessage& response);
void stopChallengeTimer();
// Avatar certification/verification:
enum VerifyState {
nonCertified, requestingFST, receivedFST, staticValidation, requestingOwner, ownerResponse,