on xenial help sign in
Make setCountry a little more correct
6d06462Michael Terry
plugins/Wizard/timezonemodel.cpp+5
@@ -203,11 +203,14 @@ void TimeZoneLocationModel::setCountry(const QString &country)
203 if (m_country == country)
203 if (m_country == country)
204 return;
204 return;
205
205
206+ beginResetModel();
207+
206 m_country = country;
208 m_country = country;
207
209
208 Q_FOREACH(GeonamesCity *city, m_countryLocations) {
210 Q_FOREACH(GeonamesCity *city, m_countryLocations) {
209 geonames_city_free(city);
211 geonames_city_free(city);
210 }
212 }
213+ m_countryLocations.clear();
211
214
212 gint num_cities = geonames_get_n_cities();
215 gint num_cities = geonames_get_n_cities();
213 for (gint i = 0; i < num_cities; i++) {
216 for (gint i = 0; i < num_cities; i++) {
@@ -219,6 +222,8 @@ void TimeZoneLocationModel::setCountry(const QString &country)
219
222
220 std::sort(m_countryLocations.begin(), m_countryLocations.end(), citycmp);
223 std::sort(m_countryLocations.begin(), m_countryLocations.end(), citycmp);
221
224
225+ endResetModel();
226+
222 Q_EMIT countryChanged(country);
227 Q_EMIT countryChanged(country);
223}
228}
224
229