History

Fix cleanup of resources for UserLocations*

Ryan Huffman committed 12 years ago

Commit a9e35291 parent e7e7bef3 files · +8 −1Browse files

Unified · Split

3 files
  1. interface/src/Menu.cpp +1 −1
  2. interface/src/UserLocationsModel.cpp +6 −0
  3. interface/src/UserLocationsModel.h +1 −0
interface/src/Menu.cpp+1−1
@@ -1187,7 +1187,7 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res · 1186 unmodified lines
11871187
11881188 void Menu::toggleLocationList() {
11891189 if (!_userLocationsWindow) {
1190− _userLocationsWindow = new UserLocationsWindow();
1190+ _userLocationsWindow = new UserLocationsWindow(Application::getInstance()->getWindow());
11911191 }
11921192 if (_userLocationsWindow->isVisible()) {
11931193 _userLocationsWindow->hide();
interface/src/UserLocationsModel.cpp+6−0
@@ -133,6 +133,11 @@ UserLocationsModel::UserLocationsModel(QObject* parent) : · 132 unmodified lines
133133 refresh();
134134 }
135135
136+UserLocationsModel::~UserLocationsModel() {
137+ qDeleteAll(_locations);
138+ _locations.clear();
139+}
140+
136141 void UserLocationsModel::update() {
137142 beginResetModel();
138143 endResetModel();
@@ -151,6 +156,7 @@ void UserLocationsModel::renameLocation(const QModelIndex& index, const QString& · 12 unmodified lines
151156 void UserLocationsModel::refresh() {
152157 if (!_updating) {
153158 beginResetModel();
159+ qDeleteAll(_locations);
154160 _locations.clear();
155161 _updating = true;
156162 endResetModel();
interface/src/UserLocationsModel.h+1−0
@@ -52,6 +52,7 @@ class UserLocationsModel : public QAbstractListModel { · 51 unmodified lines
5252 Q_OBJECT
5353 public:
5454 UserLocationsModel(QObject* parent = NULL);
55+ ~UserLocationsModel();
5556
5657 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
5758 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;