From 391b62ed32aca3b48f00b6ce85b71debaee5f9fd Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 5 Jun 2013 10:34:41 -0700 Subject: [PATCH] Make sure we don't hear back from replies after we've cleared them. --- interface/src/AvatarVoxelSystem.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/interface/src/AvatarVoxelSystem.cpp b/interface/src/AvatarVoxelSystem.cpp index 46a4212239..c50cb5b8a7 100644 --- a/interface/src/AvatarVoxelSystem.cpp +++ b/interface/src/AvatarVoxelSystem.cpp @@ -79,6 +79,7 @@ void AvatarVoxelSystem::loadVoxelsFromURL(const QUrl& url) { // cancel any current download if (_voxelReply != 0) { delete _voxelReply; + _voxelReply = 0; } killLocalVoxels(); @@ -196,17 +197,11 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 return; } - // XXXBHG - I don't know why this can happen, but when I was testing this, I used a dropbox URL - // and it resulted in a case where the bytesTotal == bytesReceived, but the _voxelReply was NULL - // which needless to say caused crashes below. I've added this quick guard to protect against - // this case, but it probably should be investigated. - if (!_voxelReply) { - return; - } - QByteArray entirety = _voxelReply->readAll(); + _voxelReply->disconnect(this); _voxelReply->deleteLater(); _voxelReply = 0; + _tree->readBitstreamToTree((unsigned char*)entirety.data(), entirety.size(), WANT_COLOR, NO_EXISTS_BITS); setupNewVoxelsForDrawing(); } @@ -214,6 +209,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 void AvatarVoxelSystem::handleVoxelReplyError() { printLog("%s\n", _voxelReply->errorString().toAscii().constData()); + _voxelReply->disconnect(this); _voxelReply->deleteLater(); _voxelReply = 0; }