1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Free some RAM when a file transfer ends

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-09-10 18:46:52 +02:00
parent 7f2edfae7d
commit 5aa5e266b2
4 changed files with 15 additions and 5 deletions

View File

@ -32,11 +32,15 @@ struct ToxFile;
class FileTransferInstance : public QObject
{
Q_OBJECT
public:
enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled};
public:
explicit FileTransferInstance(ToxFile File);
QString getHtmlImage();
uint getId(){return id;}
void setTextCursor(QTextCursor cursor);
TransfState getState() {return state;}
public slots:
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction);
@ -63,8 +67,6 @@ private:
QString wrapIntoForm(const QString &content, const QString &type, const QString &imgAstr, const QString &imgBstr);
private:
enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled};
static uint Idconter;
uint id;

View File

@ -19,7 +19,6 @@
#include <QAbstractTextDocumentLayout>
#include <QMessageBox>
#include <QScrollBar>
#include <QDebug>
ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
QTextEdit(parent)

View File

@ -19,7 +19,6 @@
#include <QTextEdit>
#include <QList>
#include <QMap>
class ChatAction;

View File

@ -18,7 +18,6 @@
#include "smileypack.h"
#include <QStringList>
#include <QBuffer>
#include <QDebug>
#include "filetransferinstance.h"
QString ChatAction::toHtmlChars(const QString &str)
@ -154,4 +153,15 @@ void FileTransferAction::updateHtml()
int end = cur.position();
cur.setPosition(pos);
cur.setPosition(end, QTextCursor::KeepAnchor);
// Free our ressources if we'll never need to update again
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
{
sender.clear();
sender.squeeze();
timestamp.clear();
timestamp.squeeze();
cur = QTextCursor();
}
}