diff options
author | Eike Ziller <eike.ziller@qt.io> | 2023-09-07 14:51:01 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2023-09-08 07:01:07 +0000 |
commit | 6defd083efb1b324903740926e0d54d195c5e429 (patch) | |
tree | 1bfef700fbc2a6cac23152b701560974842e0bc1 | |
parent | 7986776f58d038359a7d36585c9dd44191c4069a (diff) |
CtfVisualizer: Never crash with uncaught exception when loading JSON
If we retrieve a value of a type that doesn't match the actual type in
the JSON, the JSON library throws an exception.
We should have checks to avoid this, but as a global measure never let
exceptions through to Qt Creator.
Change-Id: Ibfe830d745a94810f874ccca82b83d57ea72f31e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/plugins/ctfvisualizer/ctfvisualizertool.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/ctfvisualizer/ctfvisualizertool.cpp b/src/plugins/ctfvisualizer/ctfvisualizertool.cpp index 05cf55d729..9ec24b5a33 100644 --- a/src/plugins/ctfvisualizer/ctfvisualizertool.cpp +++ b/src/plugins/ctfvisualizer/ctfvisualizertool.cpp @@ -162,8 +162,11 @@ void CtfVisualizerTool::loadJson() auto *task = new QFuture<void>(futureInterface); QThread *thread = QThread::create([this, filename, futureInterface]() { - m_traceManager->load(filename); - + try { + m_traceManager->load(filename); + } catch (...) { + // nlohmann::json can throw exceptions when requesting type that is wrong + } m_modelAggregator->moveToThread(QApplication::instance()->thread()); m_modelAggregator->setParent(this); futureInterface->reportFinished(); |