From 1573a89aac51f4efd99bdc7efda8071642291d35 Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Tue, 26 Sep 2023 17:25:20 +0800 Subject: [PATCH] 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. --- tests/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main.cpp b/tests/main.cpp index 883041b..e1860dc 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -32,7 +32,7 @@ template T stringToEnum(QMetaEnum metaEnum, const QString &str) { T ret = {}; - const auto splitted = str.split(QLatin1Char('|')); + const auto splitted = str.split(QLatin1Char('|'), Qt::SkipEmptyParts); for (const auto &value : splitted) { ret |= T(metaEnum.keyToValue(qPrintable(value))); }