mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix FT progressbar int overflow
This commit is contained in:
parent
1dca6b04ea
commit
f173a5dfa9
2
core.cpp
2
core.cpp
|
@ -334,7 +334,7 @@ void Core::onFileDataCallback(Tox*, int32_t friendnumber, uint8_t filenumber, co
|
|||
|
||||
file->file->write((char*)data,length);
|
||||
file->bytesSent += length;
|
||||
//qDebug() << QString("Core::onFileDataCallback: received %1/%2 bytes").arg(file->fileData.size()).arg(file->filesize);
|
||||
//qDebug() << QString("Core::onFileDataCallback: received %1/%2 bytes").arg(file->bytesSent).arg(file->filesize);
|
||||
emit static_cast<Core*>(core)->fileTransferInfo(file->friendId, file->fileNum,
|
||||
file->filesize, file->bytesSent, ToxFile::RECEIVING);
|
||||
}
|
||||
|
|
2
core.h
2
core.h
|
@ -219,7 +219,7 @@ signals:
|
|||
void fileUploadFinished(const QString& path);
|
||||
void fileDownloadFinished(const QString& path);
|
||||
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
|
||||
void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection direction);
|
||||
void fileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
|
||||
|
||||
void avInvite(int friendId, int callIndex, bool video);
|
||||
void avStart(int friendId, int callIndex, bool video);
|
||||
|
|
|
@ -159,7 +159,7 @@ QString FileTransfertWidget::getHumanReadableSize(int size)
|
|||
return QString().setNum(size / pow(1024, exp),'g',3).append(suffix[exp]);
|
||||
}
|
||||
|
||||
void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection Direction)
|
||||
void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction)
|
||||
{
|
||||
if (FileNum != fileNum || FriendId != friendId || Direction != direction)
|
||||
return;
|
||||
|
@ -167,7 +167,7 @@ void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int File
|
|||
int timediff = lastUpdate.secsTo(newtime);
|
||||
if (timediff <= 0)
|
||||
return;
|
||||
int diff = BytesSent - lastBytesSent;
|
||||
qint64 diff = BytesSent - lastBytesSent;
|
||||
if (diff < 0)
|
||||
{
|
||||
qWarning() << "FileTransfertWidget::onFileTransferInfo: Negative transfer speed !";
|
||||
|
@ -186,6 +186,7 @@ void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int File
|
|||
progress->setValue(0);
|
||||
else
|
||||
progress->setValue(BytesSent*100/Filesize);
|
||||
qDebug() << QString("FT: received %1/%2 bytes, progress is %3%").arg(BytesSent).arg(Filesize).arg(BytesSent*100/Filesize);
|
||||
lastUpdate = newtime;
|
||||
lastBytesSent = BytesSent;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
FileTransfertWidget(ToxFile File);
|
||||
|
||||
public slots:
|
||||
void onFileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection Direction);
|
||||
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction);
|
||||
void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction);
|
||||
void onFileTransferFinished(ToxFile File);
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ Widget::Widget(QWidget *parent) :
|
|||
qRegisterMetaType<vpx_image>("vpx_image");
|
||||
qRegisterMetaType<uint8_t>("uint8_t");
|
||||
qRegisterMetaType<int32_t>("int32_t");
|
||||
qRegisterMetaType<int64_t>("int64_t");
|
||||
qRegisterMetaType<ToxFile>("ToxFile");
|
||||
qRegisterMetaType<ToxFile::FileDirection>("ToxFile::FileDirection");
|
||||
|
||||
|
@ -471,7 +472,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
|
||||
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
|
||||
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t,QString,QByteArray)), core, SLOT(sendFile(int32_t,QString,QByteArray)));
|
||||
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
|
||||
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
|
||||
connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
|
||||
connect(newfriend->chatForm, SIGNAL(startCall(int)), core, SLOT(startCall(int)));
|
||||
|
|
Loading…
Reference in New Issue
Block a user