Changeset View
Changeset View
Standalone View
Standalone View
kcms/translations/translationsmodel.cpp
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | |||||
208 | void SelectedTranslationsModel::remove(const QString &languageCode) | 208 | void SelectedTranslationsModel::remove(const QString &languageCode) | ||
209 | { | 209 | { | ||
210 | if (languageCode.isEmpty()) { | 210 | if (languageCode.isEmpty()) { | ||
211 | return; | 211 | return; | ||
212 | } | 212 | } | ||
213 | 213 | | |||
214 | int index = m_selectedLanguages.indexOf(languageCode); | 214 | int index = m_selectedLanguages.indexOf(languageCode); | ||
215 | 215 | | |||
216 | if (index < 1) { | 216 | if (index < 0 || m_selectedLanguages.count() < 2) { | ||
davidedmundson: Changing from index < 1 to checking count makes sense, but I would still check
if (index < 0)… | |||||
I'll add the check (it's nice for sanity anyways), but the changes to the QML are actually unrelated - it's simply the delegate crashing in the Qt Quick runtime when the expression bound to enabled is re-evaluated while the delegate is being destroyed. I didn't find any better fix. hein: I'll add the check (it's nice for sanity anyways), but the changes to the QML are actually… | |||||
217 | return; | 217 | return; | ||
218 | } | 218 | } | ||
219 | 219 | | |||
220 | beginRemoveRows(QModelIndex(), index, index); | 220 | beginRemoveRows(QModelIndex(), index, index); | ||
221 | 221 | | |||
222 | m_selectedLanguages.removeAt(index); | 222 | m_selectedLanguages.removeAt(index); | ||
223 | 223 | | |||
224 | endRemoveRows(); | 224 | endRemoveRows(); | ||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
Changing from index < 1 to checking count makes sense, but I would still check
if (index < 0) {return;}
in addition to the count to catch out-of-sync erorrs. I think then you wouldn't need to complicate the QML side.