mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix uninitialized sendTimer pointer
This commit is contained in:
parent
6668cdc1e7
commit
efdc7b3a9c
9
core.cpp
9
core.cpp
|
@ -347,12 +347,15 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
|
|||
file->status = ToxFile::STOPPED;
|
||||
emit static_cast<Core*>(core)->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
|
||||
// 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)
|
||||
{
|
||||
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();
|
||||
if (file->sendTimer)
|
||||
{
|
||||
delete file->sendTimer;
|
||||
file->sendTimer = nullptr;
|
||||
}
|
||||
}
|
||||
removeFileFromQueue((bool)receive_send, file->friendId, file->fileNum);
|
||||
}
|
||||
|
|
2
core.h
2
core.h
|
@ -78,7 +78,7 @@ struct ToxFile
|
|||
ToxFile()=default;
|
||||
ToxFile(int FileNum, int FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
|
||||
: fileNum(FileNum), friendId(FriendId), fileName{FileName}, filePath{FilePath}, file{new QFile(filePath)},
|
||||
bytesSent{0}, filesize{0}, status{STOPPED}, direction{Direction} {}
|
||||
bytesSent{0}, filesize{0}, status{STOPPED}, direction{Direction}, sendTimer{nullptr} {}
|
||||
~ToxFile(){}
|
||||
void setFilePath(QString path) {filePath=path; file->setFileName(path);}
|
||||
bool open(bool write) {return write?file->open(QIODevice::ReadWrite):file->open(QIODevice::ReadOnly);}
|
||||
|
|
Loading…
Reference in New Issue
Block a user