Add error handling for mtp and gpod device
This commit is contained in:
@@ -548,12 +548,29 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
|
||||
connect(info->device_.get(), SIGNAL(TaskStarted(int)), SLOT(DeviceTaskStarted(int)));
|
||||
connect(info->device_.get(), SIGNAL(SongCountUpdated(int)), SLOT(DeviceSongCountUpdated(int)));
|
||||
|
||||
emit DeviceConnected(idx);
|
||||
connect(info->device_.get(), SIGNAL(ConnectFinished(const QString&, bool)), SLOT(DeviceConnectFinished(const QString&, bool)));
|
||||
ret->ConnectAsync();
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void DeviceManager::DeviceConnectFinished(const QString &id, bool success) {
|
||||
|
||||
DeviceInfo *info = FindDeviceById(id);
|
||||
if (!info) return;
|
||||
|
||||
QModelIndex idx = ItemToIndex(info);
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
if (success) {
|
||||
emit DeviceConnected(idx);
|
||||
}
|
||||
else {
|
||||
info->device_.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeviceInfo *DeviceManager::GetDevice(QModelIndex idx) const {
|
||||
|
||||
DeviceInfo *info = IndexToItem(idx);
|
||||
|
||||
Reference in New Issue
Block a user