summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-25 15:04:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-25 08:24:36 -0800
commit4da6a0a73261a34a71e8f95261769128c3c1df0b (patch)
tree6db2c798d5db22291a75b17b2664996e5bfed96b /qt-models/filtermodels.h
parent739b27427cfb5119eebe214c984843cd5d155620 (diff)
downloadsubsurface-4da6a0a73261a34a71e8f95261769128c3c1df0b.tar.gz
Replace bool * array by std::vector<char> in MultiFilterInterface
This replaces a dynamically allocated array of bool by std::vector<char>. 1) This makes the code shorter and less error prone, because memory management has not to be done by hand. 2) It fixes a bug in the old code: memset(checkState, false, list.count()) is wrong, because bool is not guaranteed to be the same size as char! Two notes: 1) QMap<>, QVector<>, etc. are used numerous times in the code, so this doesn't introduce a new C++ concept. Here, the std:: version is used, because there is no need for reference counting, COW semantics, etc. 2) std::vector<char> is used instead of std::vector<bool>, because the latter does a pessimization where a bitfield is used! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.h')
-rw-r--r--qt-models/filtermodels.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 992582776..cda6e2369 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -5,13 +5,14 @@
#include <QStringListModel>
#include <QSortFilterProxyModel>
#include <stdint.h>
+#include <vector>
class MultiFilterInterface {
public:
- MultiFilterInterface() : checkState(NULL), anyChecked(false) {}
+ MultiFilterInterface() : anyChecked(false) {}
virtual bool doFilter(struct dive *d, QModelIndex &index0, QAbstractItemModel *sourceModel) const = 0;
virtual void clearFilter() = 0;
- bool *checkState;
+ std::vector<char> checkState;
bool anyChecked;
};