QML UI: do not try to download from DC with empty vendor/product

Disable the Download button when one of the fields vendor, product,
connection is not filled in. The app will crash when trying.
In addition, make the underlying core code to actual download
more safe by checking this, and silently fail instead of crash.
And, yes, this is a double fix in this scenario, but the core code
is used in more places, so better safe than sorry.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2018-10-10 10:01:02 +02:00 committed by Dirk Hohndel
parent 8686b53c37
commit 8034af5ad5
2 changed files with 6 additions and 0 deletions

View file

@ -71,6 +71,10 @@ void DownloadThread::run()
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
internalData->download_table = &downloadTable;
internalData->btname = strdup(m_data->devBluetoothName().toUtf8());
if (!internalData->descriptor) {
qDebug() << "No download possible when DC type is unknown";
return;
}
#if defined(Q_OS_ANDROID)
// on Android we either use BT, a USB device, or we download via FTDI cable
if (!internalData->bluetooth_mode && (same_string(internalData->devname, "FTDI") || same_string(internalData->devname, "")))

View file

@ -273,6 +273,8 @@ Kirigami.Page {
SsrfButton {
id: download
text: qsTr("Download")
enabled: comboVendor.currentIndex != -1 && comboProduct.currentIndex != -1 &&
comboConnection.currentIndex != -1
onClicked: {
text = qsTr("Retry")
// strip any BT Name from the address