aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-12-19 19:37:27 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-12-19 19:37:27 -0500
commit598de0f03fe2c1f3c9cddfb333e7dcdb0679002b (patch)
tree56e5a543e988021033d61c562461783c32fefa2f /src/model
parentbd3b26c33da3bc2b7ce841671eb30118f32a12ef (diff)
parente0ab9aa898fdd813c73ea3c47ffb0f9b5f80e9cf (diff)
downloadmonzero-gui-598de0f03fe2c1f3c9cddfb333e7dcdb0679002b.tar.gz
monzero-gui-598de0f03fe2c1f3c9cddfb333e7dcdb0679002b.tar.xz
monzero-gui-598de0f03fe2c1f3c9cddfb333e7dcdb0679002b.zip
Merge pull request #2623
c9900c0 SubaddressAccount: drop useless getAll 'update' default argument (xiphon) e0ab9aa SubaddressAccount: fix use-after-free bug (xiphon)
Diffstat (limited to 'src/model')
-rw-r--r--src/model/SubaddressAccountModel.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/model/SubaddressAccountModel.cpp b/src/model/SubaddressAccountModel.cpp
index b8258296..c84b4532 100644
--- a/src/model/SubaddressAccountModel.cpp
+++ b/src/model/SubaddressAccountModel.cpp
@@ -59,22 +59,28 @@ QVariant SubaddressAccountModel::data(const QModelIndex &index, int role) const
if (!index.isValid() || index.row() < 0 || (unsigned)index.row() >= m_subaddressAccount->count())
return {};
- Monero::SubaddressAccountRow * sr = m_subaddressAccount->getRow(index.row());
+ QVariant result;
- QVariant result = "";
- switch (role) {
- case SubaddressAccountAddressRole:
- result = QString::fromStdString(sr->getAddress());
- break;
- case SubaddressAccountLabelRole:
- result = QString::fromStdString(sr->getLabel());
- break;
- case SubaddressAccountBalanceRole:
- result = QString::fromStdString(sr->getBalance());
- break;
- case SubaddressAccountUnlockedBalanceRole:
- result = QString::fromStdString(sr->getUnlockedBalance());
- break;
+ bool found = m_subaddressAccount->getRow(index.row(), [&result, &role](const Monero::SubaddressAccountRow &row) {
+ switch (role) {
+ case SubaddressAccountAddressRole:
+ result = QString::fromStdString(row.getAddress());
+ break;
+ case SubaddressAccountLabelRole:
+ result = QString::fromStdString(row.getLabel());
+ break;
+ case SubaddressAccountBalanceRole:
+ result = QString::fromStdString(row.getBalance());
+ break;
+ case SubaddressAccountUnlockedBalanceRole:
+ result = QString::fromStdString(row.getUnlockedBalance());
+ break;
+ default:
+ qCritical() << "Unimplemented role" << role;
+ }
+ });
+ if (!found) {
+ qCritical("%s: internal error: invalid index %d", __FUNCTION__, index.row());
}
return result;