mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-23 15:08:10 +01:00
Attempt to fix crashes in devices
This commit is contained in:
parent
a06de35aa5
commit
9b7da3e071
@ -542,6 +542,8 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
|
|||||||
}
|
}
|
||||||
info->device_ = ret;
|
info->device_ = ret;
|
||||||
QModelIndex index = ItemToIndex(info);
|
QModelIndex index = ItemToIndex(info);
|
||||||
|
if (!index.isValid()) return ret;
|
||||||
|
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
connect(info->device_.get(), SIGNAL(TaskStarted(int)), SLOT(DeviceTaskStarted(int)));
|
connect(info->device_.get(), SIGNAL(TaskStarted(int)), SLOT(DeviceTaskStarted(int)));
|
||||||
connect(info->device_.get(), SIGNAL(SongCountUpdated(int)), SLOT(DeviceSongCountUpdated(int)));
|
connect(info->device_.get(), SIGNAL(SongCountUpdated(int)), SLOT(DeviceSongCountUpdated(int)));
|
||||||
@ -639,6 +641,7 @@ void DeviceManager::DeviceTaskStarted(int id) {
|
|||||||
DeviceInfo *info = devices_[i];
|
DeviceInfo *info = devices_[i];
|
||||||
if (info->device_.get() == device) {
|
if (info->device_.get() == device) {
|
||||||
QModelIndex index = ItemToIndex(info);
|
QModelIndex index = ItemToIndex(info);
|
||||||
|
if (!index.isValid()) continue;
|
||||||
active_tasks_[id] = index;
|
active_tasks_[id] = index;
|
||||||
info->task_percentage_ = 0;
|
info->task_percentage_ = 0;
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
|
@ -308,8 +308,11 @@ void DeviceView::DeviceConnected(int row) {
|
|||||||
if (!device) return;
|
if (!device) return;
|
||||||
|
|
||||||
DeviceInfo *info = app_->device_manager()->ItemFromRow(row);
|
DeviceInfo *info = app_->device_manager()->ItemFromRow(row);
|
||||||
|
if (!info) return;
|
||||||
QModelIndex index = app_->device_manager()->ItemToIndex(info);
|
QModelIndex index = app_->device_manager()->ItemToIndex(info);
|
||||||
|
if (!index.isValid()) return;
|
||||||
QModelIndex sort_idx = sort_model_->mapFromSource(index);
|
QModelIndex sort_idx = sort_model_->mapFromSource(index);
|
||||||
|
if (!sort_idx.isValid()) return;
|
||||||
|
|
||||||
QSortFilterProxyModel *sort_model = new QSortFilterProxyModel(device->model());
|
QSortFilterProxyModel *sort_model = new QSortFilterProxyModel(device->model());
|
||||||
sort_model->setSourceModel(device->model());
|
sort_model->setSourceModel(device->model());
|
||||||
@ -326,6 +329,7 @@ void DeviceView::DeviceDisconnected(int row) {
|
|||||||
DeviceInfo *info = app_->device_manager()->ItemFromRow(row);
|
DeviceInfo *info = app_->device_manager()->ItemFromRow(row);
|
||||||
if (!info) return;
|
if (!info) return;
|
||||||
QModelIndex index = app_->device_manager()->ItemToIndex(info);
|
QModelIndex index = app_->device_manager()->ItemToIndex(info);
|
||||||
|
if (!index.isValid()) return;
|
||||||
merged_model_->RemoveSubModel(sort_model_->mapFromSource(index));
|
merged_model_->RemoveSubModel(sort_model_->mapFromSource(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user