diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-19 10:35:49 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-06-01 21:55:07 +0200 |
commit | 97269ab2949abc0deced5545ff14d41603f46d41 (patch) | |
tree | 562851f57397e514f25207ec4cfb0acea8a329bf /src/gui/kernel/qkeysequence.cpp | |
parent | c0bb5b2aa199059ad1329dbfd81d8a17a5d29dfe (diff) |
QKeySequence: statically assert the sortedness of the MacSpecialKey array
This array has, in the past, silently failed this test
(cf. 5d8f815e101da3ae9cd6a666cc097853f52b21da). Make sure it doesn't
happen again.
Change-Id: I26192749d43de4a7add9d14c7ca04391c1799525
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui/kernel/qkeysequence.cpp')
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 02f994915f..2507f8720a 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -18,6 +18,7 @@ #endif #include <algorithm> +#include <q20algorithm.h> QT_BEGIN_NAMESPACE @@ -62,6 +63,11 @@ static constexpr MacSpecialKey entries[] = { { Qt::Key_Eject, 0x23CF }, }; +static constexpr bool operator<(const MacSpecialKey &lhs, const MacSpecialKey &rhs) +{ + return lhs.key < rhs.key; +} + static constexpr bool operator<(const MacSpecialKey &lhs, int rhs) { return lhs.key < rhs; @@ -72,6 +78,7 @@ static constexpr bool operator<(int lhs, const MacSpecialKey &rhs) return lhs < rhs.key; } +static_assert(q20::is_sorted(std::begin(entries), std::end(entries))); QChar qt_macSymbolForQtKey(int key) { |