From c1ca54a1d1f0f2084210eba434f7930fb853b545 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 17 Jul 2018 20:17:46 +0200 Subject: [PATCH] bugfix --- src/core/marketplace.cpp | 5 ++++- src/gui/sellermodel.cpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/marketplace.cpp b/src/core/marketplace.cpp index f0e9d8b..14243f1 100644 --- a/src/core/marketplace.cpp +++ b/src/core/marketplace.cpp @@ -31,11 +31,14 @@ int Marketplace::getNextSellerNo() [](const std::unique_ptr& a, const std::unique_ptr& b) -> bool { return a->getSellerNo() < b->getSellerNo(); }); + if (iter == sellers_.end()) + return 1; return (*iter)->getSellerNo() + 1; } int Marketplace::getNumSellersDelete() { - int count = std::count_if(sellers_.begin(), sellers_.end(), [](const auto& a){return a->getState() == Seller::State::DELETE;}); + int count = std::count_if(sellers_.begin(), sellers_.end(), + [](const auto& a) { return a->getState() == Seller::State::DELETE; }); return count; } \ No newline at end of file diff --git a/src/gui/sellermodel.cpp b/src/gui/sellermodel.cpp index 923cc1c..109d5df 100644 --- a/src/gui/sellermodel.cpp +++ b/src/gui/sellermodel.cpp @@ -21,6 +21,9 @@ QVariant SellerModel::data(const QModelIndex& index, int role) const if (role != Qt::DisplayRole) return QVariant(); + if (marketplace_->getSellers().size() == 0) + return QVariant(); + Seller* seller = marketplace_->getSellers().at(index.row()).get(); /* if (seller->getState() == Seller::State::DELETE)