Merge pull request #6521 from jbroadus/handle-connect-error-from-dialog

Properly handle connect errors when initiated from properties dialog.
This commit is contained in:
John Maguire 2020-01-08 10:42:55 +00:00 committed by GitHub
commit 8cfbc5bad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -586,6 +586,7 @@ void DeviceManager::DeviceConnectFinished(const QString& id, bool success) {
emit DeviceConnected(idx);
} else {
info->device_.reset();
emit dataChanged(idx, idx);
}
}

View File

@ -87,6 +87,9 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
void Disconnect(QModelIndex idx);
void Forget(QModelIndex idx);
void UnmountAsync(QModelIndex idx);
bool IsConnected(QModelIndex idx) {
return GetConnectedDevice(idx) != nullptr;
}
void SetDeviceOptions(QModelIndex idx, const QString& friendly_name,
const QString& icon_name,

View File

@ -264,6 +264,13 @@ void DeviceProperties::OpenDevice() { manager_->Connect(index_); }
void DeviceProperties::UpdateFormatsFinished(QFuture<bool> future) {
updating_formats_ = false;
// Check if the device was disconnected while the thread was running. In that
// case, ModelChanged would be called and the not connected page would be
// shown.
if (!manager_->IsConnected(index_)) {
return;
}
if (!future.result()) {
supported_formats_.clear();
}