dbhub: Fix sporadic crashes when selecting an identity

This fixes a sporadic crash when selecting an identity in the Remote
dock. It happened because selecting an identity removes the first dummy
entry in the drop down list of identities which for some reason emits
the signal which then calls the same function to update the root dir
again. Depending on the timing of the network requests this could lead
to some confusion when building the tree structure.

Also fix an off-by-one error when building the tree structure.

See issue #2333.
This commit is contained in:
Martin Kleusberg
2020-07-18 10:38:17 +02:00
parent 9fcba5a807
commit 5341112bbe
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -119,7 +119,11 @@ void RemoteDock::setNewIdentity(const QString& identity)
// Check if the dummy item is still there and remove it if it is
if(ui->comboUser->itemData(0) == "dummy")
{
ui->comboUser->blockSignals(true);
ui->comboUser->removeItem(0);
ui->comboUser->blockSignals(false);
}
// Get certificate file name
QString cert = ui->comboUser->itemData(ui->comboUser->findText(identity), Qt::UserRole).toString();
+1 -1
View File
@@ -158,8 +158,8 @@ void RemoteModel::parseDirectoryListing(const QString& text, const QVariant& use
}
// Insert data
beginInsertRows(parent, 0, static_cast<int>(array.size()));
std::vector<RemoteModelItem*> items = RemoteModelItem::loadArray(array, parentItem);
beginInsertRows(parent, 0, static_cast<int>(items.size() - 1));
for(RemoteModelItem* item : items)
parentItem->appendChild(item);
endInsertRows();