aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/generichighlighter
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-04-12 19:49:07 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2016-04-13 11:22:23 +0000
commit24df8abbcabbbddfa692106c1817477db1ee9397 (patch)
treecb723282fe5729aeb0971ca72f9f430ff04fbd13 /src/plugins/texteditor/generichighlighter
parent641b5114308ad7d2087899e70d15d316df52e4d4 (diff)
Generic Highlighter: Remove warnings and thread safety issues
QNetworkAccessManager is not thread safe, and creates child objects that need to live in the same thread as the manager, so we need to create one network access manager per thread. Change-Id: I76b8a3cb8a7c7665bc6a5f3d49496096903eeb87 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/texteditor/generichighlighter')
-rw-r--r--src/plugins/texteditor/generichighlighter/definitiondownloader.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp b/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp
index 0feb75e489..680d811148 100644
--- a/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp
+++ b/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp
@@ -39,10 +39,8 @@
namespace TextEditor {
namespace Internal {
-static QNetworkReply *getData(const QUrl &url)
+static QNetworkReply *getData(QNetworkAccessManager *manager, const QUrl &url)
{
- Utils::NetworkAccessManager *manager = Utils::NetworkAccessManager::instance();
-
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
@@ -59,10 +57,12 @@ DefinitionDownloader::DefinitionDownloader(const QUrl &url, const QString &local
void DefinitionDownloader::run()
{
+ Utils::NetworkAccessManager manager;
+
int currentAttempt = 0;
const int maxAttempts = 5;
while (currentAttempt < maxAttempts) {
- QScopedPointer<QNetworkReply> reply(getData(m_url));
+ QScopedPointer<QNetworkReply> reply(getData(&manager, m_url));
if (reply->error() != QNetworkReply::NoError) {
m_status = NetworkError;
return;