Fix cleanup of resources for UserLocations*

This commit is contained in:
Ryan Huffman 2014-07-01 17:59:49 -07:00
parent e7e7bef506
commit a9e352981a
3 changed files with 8 additions and 1 deletions

View file

@ -1187,7 +1187,7 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res
void Menu::toggleLocationList() {
if (!_userLocationsWindow) {
_userLocationsWindow = new UserLocationsWindow();
_userLocationsWindow = new UserLocationsWindow(Application::getInstance()->getWindow());
}
if (_userLocationsWindow->isVisible()) {
_userLocationsWindow->hide();

View file

@ -133,6 +133,11 @@ UserLocationsModel::UserLocationsModel(QObject* parent) :
refresh();
}
UserLocationsModel::~UserLocationsModel() {
qDeleteAll(_locations);
_locations.clear();
}
void UserLocationsModel::update() {
beginResetModel();
endResetModel();
@ -151,6 +156,7 @@ void UserLocationsModel::renameLocation(const QModelIndex& index, const QString&
void UserLocationsModel::refresh() {
if (!_updating) {
beginResetModel();
qDeleteAll(_locations);
_locations.clear();
_updating = true;
endResetModel();

View file

@ -52,6 +52,7 @@ class UserLocationsModel : public QAbstractListModel {
Q_OBJECT
public:
UserLocationsModel(QObject* parent = NULL);
~UserLocationsModel();
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;