# # # patch "src/model/Keys.cpp" # from [5f6eedc7c6099bdaf294cced4707c935ba47c759] # to [9283be02e0195529d98eca218d0736b5666836a4] # # patch "src/model/Keys.h" # from [2ac3f606bafd5e8d70b9c23a33f85e841bb0699e] # to [c8a97fb1a99d0e451cd939434b4332443e403d95] # ============================================================ --- src/model/Keys.cpp 5f6eedc7c6099bdaf294cced4707c935ba47c759 +++ src/model/Keys.cpp 9283be02e0195529d98eca218d0736b5666836a4 @@ -26,7 +26,10 @@ Keys::Keys(QObject * parent, const Datab : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) {} -Keys::~Keys() {} +Keys::~Keys() +{ + qDeleteAll(keys); +} void Keys::readKeys() { @@ -54,7 +57,7 @@ void Keys::processTaskResult(const Monot { Stanza stanza = list.at(i); - Key key; + Key * key = new Key(); bool isItem = false; for (int j=0, size2 = stanza.size(); j < size2; j++) @@ -69,21 +72,21 @@ void Keys::processTaskResult(const Monot if (entry.sym == "hash") { I(!entry.hash.isNull()); - key.hash = entry.hash; + key->hash = entry.hash; continue; } if (entry.sym == "given_name") { I(entry.vals.size() == 1); - key.given_name = entry.vals.at(0); + key->given_name = entry.vals.at(0); continue; } if (entry.sym == "local_name") { I(entry.vals.size() == 1); - key.local_name = entry.vals.at(0); + key->local_name = entry.vals.at(0); continue; } @@ -93,13 +96,13 @@ void Keys::processTaskResult(const Monot { if (entry.vals.at(k) == "database") { - key.public_locations |= Key::Database; + key->public_locations |= Key::Database; continue; } if (entry.vals.at(k) == "keystore") { - key.public_locations |= Key::Keystore; + key->public_locations |= Key::Keystore; continue; } @@ -114,13 +117,13 @@ void Keys::processTaskResult(const Monot { if (entry.vals.at(k) == "database") { - key.private_locations |= Key::Database; + key->private_locations |= Key::Database; continue; } if (entry.vals.at(k) == "keystore") { - key.private_locations |= Key::Keystore; + key->private_locations |= Key::Keystore; continue; } @@ -162,15 +165,15 @@ QVariant Keys::data(const QModelIndex & int row = index.row(); if (row >= keys.size()) return QVariant(); - Key key(keys.at(row)); + Key * key = keys.at(row); switch (index.column()) { - case 0: return QVariant(key.hash); - case 1: return QVariant(key.given_name); - case 2: return QVariant(key.local_name); - case 3: return QVariant(getLocationString(key.public_locations)); - case 4: return QVariant(getLocationString(key.private_locations)); + case 0: return QVariant(key->hash); + case 1: return QVariant(key->given_name); + case 2: return QVariant(key->local_name); + case 3: return QVariant(getLocationString(key->public_locations)); + case 4: return QVariant(getLocationString(key->private_locations)); } return QVariant(); @@ -222,8 +225,7 @@ QModelIndex Keys::index(int row, int col } if (row >= keys.size()) return QModelIndex(); - Key key(keys.at(row)); - return createIndex(row, column, &key); + return createIndex(row, column, keys.at(row)); } QModelIndex Keys::parent(const QModelIndex & index) const ============================================================ --- src/model/Keys.h 2ac3f606bafd5e8d70b9c23a33f85e841bb0699e +++ src/model/Keys.h c8a97fb1a99d0e451cd939434b4332443e403d95 @@ -33,7 +33,6 @@ struct Key { int private_locations; Key() : public_locations(0), private_locations(0) {}; }; -typedef QList KeyList; class Keys : public QAbstractItemModel, public AutomateCommand { @@ -60,7 +59,7 @@ private: private: void processTaskResult(const MonotoneTask &); QString getLocationString(int) const; - KeyList keys; + QList keys; DatabaseFile databaseFile; };