warn upon json parse error
This commit is contained in:
parent
75a792d0fb
commit
aef6e08f60
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user