Fix assertion when removing all elements from model

pull/841/head
Jon Beniston 2021-04-13 10:14:54 +01:00
rodzic 6ad057e935
commit 53cccf7298
4 zmienionych plików z 36 dodań i 24 usunięć

Wyświetl plik

@ -378,14 +378,17 @@ public:
} }
void removeAllAirports() { void removeAllAirports() {
beginRemoveRows(QModelIndex(), 0, m_airports.count()); if (m_airports.count() > 0)
m_airports.clear(); {
m_airportDataFreq.clear(); beginRemoveRows(QModelIndex(), 0, m_airports.count() - 1);
m_airportDataFreqRows.clear(); m_airports.clear();
m_showFreq.clear(); m_airportDataFreq.clear();
m_azimuth.clear(); m_airportDataFreqRows.clear();
m_elevation.clear(); m_showFreq.clear();
endRemoveRows(); m_azimuth.clear();
m_elevation.clear();
endRemoveRows();
}
} }
int rowCount(const QModelIndex &parent = QModelIndex()) const override { int rowCount(const QModelIndex &parent = QModelIndex()) const override {

Wyświetl plik

@ -143,12 +143,15 @@ public:
} }
void removeAllVORs() { void removeAllVORs() {
beginRemoveRows(QModelIndex(), 0, m_vors.count()); if (m_vors.count() > 0)
m_vors.clear(); {
m_selected.clear(); beginRemoveRows(QModelIndex(), 0, m_vors.count() - 1);
m_radials.clear(); m_vors.clear();
m_vorGUIs.clear(); m_selected.clear();
endRemoveRows(); m_radials.clear();
m_vorGUIs.clear();
endRemoveRows();
}
} }
QHash<int, QByteArray> roleNames() const { QHash<int, QByteArray> roleNames() const {

Wyświetl plik

@ -351,10 +351,13 @@ public:
void removeAll() void removeAll()
{ {
beginRemoveRows(QModelIndex(), 0, m_items.count()); if (m_items.count() > 0)
m_items.clear(); {
m_selected.clear(); beginRemoveRows(QModelIndex(), 0, m_items.count());
endRemoveRows(); m_items.clear();
m_selected.clear();
endRemoveRows();
}
} }
void setDisplayNames(bool displayNames) void setDisplayNames(bool displayNames)

Wyświetl plik

@ -144,12 +144,15 @@ public:
} }
void removeAllVORs() { void removeAllVORs() {
beginRemoveRows(QModelIndex(), 0, m_vors.count()); if (m_vors.count() > 0)
m_vors.clear(); {
m_selected.clear(); beginRemoveRows(QModelIndex(), 0, m_vors.count() - 1);
m_radials.clear(); m_vors.clear();
m_vorGUIs.clear(); m_selected.clear();
endRemoveRows(); m_radials.clear();
m_vorGUIs.clear();
endRemoveRows();
}
} }
QHash<int, QByteArray> roleNames() const { QHash<int, QByteArray> roleNames() const {