Skip empty parts for stringToEnum template
metaEnum.keyToValue("") will results all flags get set, thus creating a enum with empty (0) flags become impossible. This patch fixes that.
This commit is contained in:
parent
721c0ae334
commit
1573a89aac
|
@ -32,7 +32,7 @@ template<typename T>
|
||||||
T stringToEnum(QMetaEnum metaEnum, const QString &str)
|
T stringToEnum(QMetaEnum metaEnum, const QString &str)
|
||||||
{
|
{
|
||||||
T ret = {};
|
T ret = {};
|
||||||
const auto splitted = str.split(QLatin1Char('|'));
|
const auto splitted = str.split(QLatin1Char('|'), Qt::SkipEmptyParts);
|
||||||
for (const auto &value : splitted) {
|
for (const auto &value : splitted) {
|
||||||
ret |= T(metaEnum.keyToValue(qPrintable(value)));
|
ret |= T(metaEnum.keyToValue(qPrintable(value)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue