mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 23:05:48 +02:00
messaging: run previewengine on its own thread
Change-Id: Iff267600c0802fbadedb58174b5fe65bbd1a443f
This commit is contained in:
parent
692ba0d5a8
commit
2343f34b4f
2 changed files with 15 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "previewengine.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QThread>
|
||||
|
||||
const QRegularExpression PreviewEngine::newlineRe("\\r?\\n");
|
||||
|
||||
|
@ -25,10 +26,21 @@ PreviewEngine::PreviewEngine(ConnectivityMonitor* cm, QObject* parent)
|
|||
: NetworkManager(cm, parent)
|
||||
, htmlParser_(new HtmlParser(this))
|
||||
{
|
||||
// Run this object in a separate thread.
|
||||
thread_ = new QThread();
|
||||
moveToThread(thread_);
|
||||
thread_->start();
|
||||
|
||||
// Connect on a queued connection to avoid blocking caller thread.
|
||||
connect(this, &PreviewEngine::parseLink, this, &PreviewEngine::onParseLink, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
PreviewEngine::~PreviewEngine()
|
||||
{
|
||||
thread_->quit();
|
||||
thread_->wait();
|
||||
}
|
||||
|
||||
QString
|
||||
PreviewEngine::getTagContent(const QList<QString>& tags, const QString& value)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ class PreviewEngine final : public NetworkManager
|
|||
Q_DISABLE_COPY(PreviewEngine)
|
||||
public:
|
||||
PreviewEngine(ConnectivityMonitor* cm, QObject* parent = nullptr);
|
||||
~PreviewEngine() = default;
|
||||
~PreviewEngine();
|
||||
|
||||
Q_SIGNALS:
|
||||
void parseLink(const QString& messageId, const QString& link);
|
||||
|
@ -45,4 +45,6 @@ private:
|
|||
QString getImage(const QList<QString>& metaTags);
|
||||
|
||||
static const QRegularExpression newlineRe;
|
||||
|
||||
QThread* thread_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue