From 107252d2e442f72a885a6b120a51b8dbfdea4ce7 Mon Sep 17 00:00:00 2001 From: Daniel Trnka Date: Sun, 10 Nov 2024 15:20:29 +0100 Subject: [PATCH] udp_server: fix crash when dialog opens for the first time (#1002) UDP server dialogue crashes when theres no protocol stored in settings, as the default is wrongly "JSON", but it should be "json". This patch uses default "json" even when there is wrong protocol in settings to prevent further crashes. --- plotjuggler_plugins/DataStreamUDP/udp_server.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plotjuggler_plugins/DataStreamUDP/udp_server.cpp b/plotjuggler_plugins/DataStreamUDP/udp_server.cpp index 1e24008cf..cdd2b714f 100644 --- a/plotjuggler_plugins/DataStreamUDP/udp_server.cpp +++ b/plotjuggler_plugins/DataStreamUDP/udp_server.cpp @@ -97,9 +97,13 @@ bool UDP_Server::start(QStringList*) // load previous values QSettings settings; - QString protocol = settings.value("UDP_Server::protocol", "JSON").toString(); QString address_str = settings.value("UDP_Server::address", "127.0.0.1").toString(); int port = settings.value("UDP_Server::port", 9870).toInt(); + QString protocol = settings.value("UDP_Server::protocol").toString(); + if (parserFactories()->find(protocol) == parserFactories()->end()) + { + protocol = "json"; + } dialog.ui->lineEditAddress->setText(address_str); dialog.ui->lineEditPort->setText(QString::number(port));