CtfVisualizer: Fix multithreading issues

Simplify the CtfVisualizerTool::loadJson(). Don't create a QThread
manually, but use TaskTree with AsyncTask instead.
Move pure parsing into the separate thread, and leave the
nlohmann::json event handling in the main thread.
Avoid moving m_modelAggregator between threads.

Fixes: QTCREATORBUG-29657
Change-Id: I0c6a9a4ea8298dbbdbafcddd338d39ad73c3f82b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2023-09-27 16:16:43 +02:00
parent c32022f085
commit c05f9cacc6
4 changed files with 103 additions and 120 deletions

View File

@@ -5,13 +5,11 @@
#include "json/json.hpp"
#include <QHash>
#include <QList>
#include <QMap>
#include <QObject>
#include <QVector>
namespace Timeline {
class TimelineModelAggregator;
}
namespace Timeline { class TimelineModelAggregator; }
namespace CtfVisualizer {
namespace Internal {
@@ -34,7 +32,6 @@ public:
void addEvent(const nlohmann::json &event);
void load(const QString &filename);
void finalize();
bool isEmpty() const;
@@ -46,6 +43,9 @@ public:
void setThreadRestriction(const QString &tid, bool restrictToThisThread);
bool isRestrictedTo(const QString &tid) const;
void updateStatistics();
void clearAll();
signals:
void detailsRequested(const QString &title);
@@ -53,10 +53,6 @@ protected:
void addModelForThread(const QString &threadId, const QString &processId);
void addModelsToAggregator();
void updateStatistics();
void clearAll();
Timeline::TimelineModelAggregator *const m_modelAggregator;
CtfStatisticsModel *const m_statisticsModel;