From 6defd083efb1b324903740926e0d54d195c5e429 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 7 Sep 2023 14:51:01 +0200 Subject: 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 Reviewed-by: --- src/plugins/ctfvisualizer/ctfvisualizertool.cpp | 7 +++++-- 1 file 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(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(); -- cgit v1.2.3