1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-08-31 13:07:31 +02:00
parent 4a66026676
commit 0deba0ad24

View File

@ -346,7 +346,14 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
.arg(file->fileNum).arg(file->friendId);
file->status = ToxFile::STOPPED;
emit static_cast<Core*>(core)->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
while (file->sendTimer) QThread::msleep(1); // Wait for sendAllFileData to return before deleting the ToxFile
// Wait for sendAllFileData to return before deleting the ToxFile, we MUST ensure this or we'll use after free
while (file->sendTimer)
{
if (!file->sendTimer->isActive()) // Force it to clean itself up if it isn't already done
sendAllFileData(static_cast<Core*>(core), file);
QThread::msleep(1);
qApp->processEvents();
}
removeFileFromQueue((bool)receive_send, file->friendId, file->fileNum);
}
else if (receive_send == 1 && control_type == TOX_FILECONTROL_FINISHED)
@ -496,7 +503,7 @@ void Core::pauseResumeFileSend(int friendId, int fileNum)
}
if (!file)
{
qWarning("Core::cancelFileSend: No such file in queue");
qWarning("Core::pauseResumeFileSend: No such file in queue");
return;
}
if (file->status == ToxFile::TRANSMITTING)