mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-07 06:35:15 +01:00
Properly delete ignored DeviceInfo object
Since the SimpleTreeItem constructor variant used from LoadAllDevices adds the object to the parent's children list, use the parent's Delete method to destroy it.
This commit is contained in:
parent
1ef5ec2590
commit
0d25a1b39c
@ -136,6 +136,7 @@ DeviceManager::~DeviceManager() {
|
||||
delete root_;
|
||||
}
|
||||
|
||||
// This runs concurrently.
|
||||
void DeviceManager::LoadAllDevices() {
|
||||
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
||||
DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
|
||||
@ -166,8 +167,11 @@ void DeviceManager::AddDeviceFromDb(DeviceInfo* info) {
|
||||
existing->icon_ = info->icon_;
|
||||
QModelIndex idx = ItemToIndex(existing);
|
||||
if (idx.isValid()) emit dataChanged(idx, idx);
|
||||
// Discard the info loaded from the database.
|
||||
delete info;
|
||||
|
||||
// Discard the info loaded from the database. This doesn't use
|
||||
// begin/endRemoveRows, but beginInsertRows has not yet been called to
|
||||
// notify listeners of the existence.
|
||||
root_->Delete(info->row);
|
||||
} else {
|
||||
qLog(Info) << "Device added from database: " << info->friendly_name_;
|
||||
beginInsertRows(ItemToIndex(root_), devices_.count(), devices_.count());
|
||||
|
Loading…
x
Reference in New Issue
Block a user