diff options
author | ccolin | 2021-01-04 17:59:01 +0100 |
---|---|---|
committer | ccolin | 2021-01-04 17:59:01 +0100 |
commit | aef6e08f6064acf3430a59e7bd6aff214ee1e065 (patch) | |
tree | 105d7580dae374ef54117c4078f0b7728fb238c7 /src/main_window.cc | |
parent | 75a792d0fbe93444a3f62a18594aa0d2090b9276 (diff) |
warn upon json parse error
Diffstat (limited to 'src/main_window.cc')
-rw-r--r-- | src/main_window.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main_window.cc b/src/main_window.cc index ad3a7fe..dbe82a9 100644 --- a/src/main_window.cc +++ b/src/main_window.cc @@ -12,7 +12,6 @@ MainWindow::MainWindow(QWidget *parent) { (void) parent; connect(&glw, &OpenGLWidget::initialized, this, &MainWindow::onOpenGLWidgetInitialized); - // connect(&timer, &QTimer::timeout, this, &MainWindow::step); setCentralWidget(&glw); addToolBar(Qt::TopToolBarArea, &top_tb); open_action = top_tb.addAction("Ouvrir…", [&]() { @@ -59,7 +58,12 @@ void MainWindow::open(const QString &path) { return; } QByteArray data = file.readAll(); - QJsonDocument json_doc = QJsonDocument::fromJson(data); + QJsonParseError error; + QJsonDocument json_doc = QJsonDocument::fromJson(data, &error); + if (error.error != QJsonParseError::NoError) { + qWarning() << "Erreur lors de la lecture du ficher JSON:" << error.errorString(); + return; + } if (dc) delete dc; glw.meshes.clear(); dc = new DroneController(json_doc.object()); |