summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qflags.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-05-03 00:18:57 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-05-13 14:28:45 +0200
commit81bb764e9886de17260d6c7d01ff7e39c23f47f4 (patch)
treed0a0ad3431b3acadf99b85e7e70fddbacd7be438 /src/corelib/global/qflags.h
parent23780891a50ba678714f7e0a4cf43a0f8164b440 (diff)
QFlags::testFlag: code tidies
If the condition Int(flag) != 0 is false, it means that flag == 0. So just check i against 0, which is more in line with what testFlag behavior is documented to do. Change-Id: Ia75fa07eee65e67a769fda7c020bf17ada77e9a3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qflags.h')
-rw-r--r--src/corelib/global/qflags.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index 82fcbdd54d..c6ecb1ea47 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -145,7 +145,7 @@ public:
constexpr inline bool operator!() const noexcept { return !i; }
- constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); }
+ constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(0) ); }
constexpr inline QFlags &setFlag(Enum flag, bool on = true) noexcept
{
return on ? (*this |= flag) : (*this &= ~QFlags(flag));