Check when empty to avoid a crash
This commit is contained in:
parent
fc3e2eff1d
commit
af02ca7c74
1 changed files with 5 additions and 3 deletions
|
@ -62,9 +62,11 @@ void DevicesModel::deviceAdded(const QString& id)
|
||||||
|
|
||||||
//Full refresh
|
//Full refresh
|
||||||
Q_UNUSED(id);
|
Q_UNUSED(id);
|
||||||
beginRemoveRows(QModelIndex(), 0, m_deviceList.count() - 1);
|
if (m_deviceList.count() > 0) {
|
||||||
m_deviceList.clear();
|
beginRemoveRows(QModelIndex(), 0, m_deviceList.count() - 1);
|
||||||
endRemoveRows();
|
m_deviceList.clear();
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
QList<QString> deviceIds = m_dbusInterface->devices();
|
QList<QString> deviceIds = m_dbusInterface->devices();
|
||||||
Q_FOREACH(const QString& id, deviceIds) {
|
Q_FOREACH(const QString& id, deviceIds) {
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount() + 1);
|
beginInsertRows(QModelIndex(), rowCount(), rowCount() + 1);
|
||||||
|
|
Loading…
Reference in a new issue