From ab126dd9b7bdb7dace5c88b3ff582057ebc81782 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Mon, 21 Oct 2024 22:54:34 +0200 Subject: [PATCH] Fix possible exception in dashboard if the 'model' property of an android device is not defined --- dashboard/main_window.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dashboard/main_window.cpp b/dashboard/main_window.cpp index 45c77a36..6a15a000 100644 --- a/dashboard/main_window.cpp +++ b/dashboard/main_window.cpp @@ -292,9 +292,18 @@ void main_window::on_android_device_list_changed(const std::vector if (std::ranges::none_of(usb_actions, [&](const std::pair> & x) { return x.first == device.serial(); })) { qDebug() << "Detected" << QString::fromStdString(device.serial()); + for (auto & [key, value]: device.properties()) + { + qDebug() << " " << QString::fromStdString(key) << ":" << QString::fromStdString(value); + } std::unique_ptr device_action = std::make_unique(this); - device_action->setText(QString::fromStdString(device.properties().at("model"))); + + if (auto model = device.properties().find("model"); model != device.properties().end()) + device_action->setText(QString::fromStdString(model->second)); + else + device_action->setText("Unknown model"); + usb_device_menu->addAction(device_action.get()); device_action->setData(QString::fromStdString(device.serial()));