diff --git a/filetransferinstance.h b/filetransferinstance.h index e17f03327..39e3bf380 100644 --- a/filetransferinstance.h +++ b/filetransferinstance.h @@ -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; diff --git a/widget/chatareawidget.cpp b/widget/chatareawidget.cpp index cb9037e92..bd261f3bf 100644 --- a/widget/chatareawidget.cpp +++ b/widget/chatareawidget.cpp @@ -19,7 +19,6 @@ #include #include #include -#include ChatAreaWidget::ChatAreaWidget(QWidget *parent) : QTextEdit(parent) diff --git a/widget/chatareawidget.h b/widget/chatareawidget.h index a5e531859..cf9026877 100644 --- a/widget/chatareawidget.h +++ b/widget/chatareawidget.h @@ -19,7 +19,6 @@ #include #include -#include class ChatAction; diff --git a/widget/tool/chataction.cpp b/widget/tool/chataction.cpp index 5ac71ca9a..f362e2b81 100644 --- a/widget/tool/chataction.cpp +++ b/widget/tool/chataction.cpp @@ -18,7 +18,6 @@ #include "smileypack.h" #include #include -#include #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(); + } }