DeviceUserArgs: UI: fixed possible segfault when tree item pointer is null

pull/381/head
f4exb 2019-06-30 04:19:28 +02:00
rodzic e317b06fc9
commit ae787a2768
1 zmienionych plików z 24 dodań i 12 usunięć

Wyświetl plik

@ -123,20 +123,28 @@ void DeviceUserArgsDialog::on_importDevice_clicked(bool checked)
{
(void) checked;
QTreeWidgetItem *deviceItem = ui->deviceTree->currentItem();
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.addDeviceArgs(deviceItem->text(0), sequence, "");
displayArgsByDevice();
if (deviceItem)
{
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.addDeviceArgs(deviceItem->text(0), sequence, "");
displayArgsByDevice();
}
}
void DeviceUserArgsDialog::on_deleteArgs_clicked(bool checked)
{
(void) checked;
QTreeWidgetItem *deviceItem = ui->argsTree->currentItem();
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.deleteDeviceArgs(deviceItem->text(0), sequence);
displayArgsByDevice();
if (deviceItem)
{
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.deleteDeviceArgs(deviceItem->text(0), sequence);
displayArgsByDevice();
}
}
void DeviceUserArgsDialog::on_argsTree_currentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previousItem)
@ -148,8 +156,12 @@ void DeviceUserArgsDialog::on_argsTree_currentItemChanged(QTreeWidgetItem* curre
void DeviceUserArgsDialog::on_argStringEdit_editingFinished()
{
QTreeWidgetItem *deviceItem = ui->argsTree->currentItem();
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.updateDeviceArgs(deviceItem->text(0), sequence, ui->argStringEdit->text());
displayArgsByDevice();
if (deviceItem)
{
bool ok;
int sequence = deviceItem->text(1).toInt(&ok);
m_deviceUserArgsCopy.updateDeviceArgs(deviceItem->text(0), sequence, ui->argStringEdit->text());
displayArgsByDevice();
}
}