warn upon json parse error
This commit is contained in:
parent
75a792d0fb
commit
aef6e08f60
@ -12,7 +12,6 @@ MainWindow::MainWindow(QWidget *parent) {
|
|||||||
(void) parent;
|
(void) parent;
|
||||||
connect(&glw, &OpenGLWidget::initialized,
|
connect(&glw, &OpenGLWidget::initialized,
|
||||||
this, &MainWindow::onOpenGLWidgetInitialized);
|
this, &MainWindow::onOpenGLWidgetInitialized);
|
||||||
// connect(&timer, &QTimer::timeout, this, &MainWindow::step);
|
|
||||||
setCentralWidget(&glw);
|
setCentralWidget(&glw);
|
||||||
addToolBar(Qt::TopToolBarArea, &top_tb);
|
addToolBar(Qt::TopToolBarArea, &top_tb);
|
||||||
open_action = top_tb.addAction("Ouvrir…", [&]() {
|
open_action = top_tb.addAction("Ouvrir…", [&]() {
|
||||||
@ -59,7 +58,12 @@ void MainWindow::open(const QString &path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray data = file.readAll();
|
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;
|
if (dc) delete dc;
|
||||||
glw.meshes.clear();
|
glw.meshes.clear();
|
||||||
dc = new DroneController(json_doc.object());
|
dc = new DroneController(json_doc.object());
|
||||||
|
Loading…
Reference in New Issue
Block a user