summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-17 09:23:29 +0100
committerDavid Faure <david.faure@kdab.com>2015-02-26 09:49:10 +0000
commit05e0dfa0060aab80afc696161226b2ab0cddfbf9 (patch)
treec848d937af71a450f940d4226cb867429ad976a5 /src/corelib/kernel
parent081afb2a16eb9a85458d32b2365b301115fd2119 (diff)
Reverse iteration in QMetaEnum::valueToKeys().
Otherwise, values that are composed of others are not handled correctly. For example, Qt::Dialog|Qt::FramelessWindowHint (Qt::Dialog=0x2|Qt::Window) is currently output as "Window|FramelessWindowHint" since Qt::Window matches first and its bits are removed from the flag value so that Qt::Dialog in the next iteration no longer matches. Change-Id: I67db5c977c75f887392aa8f345c5e6e9d82c5c26 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index e7be2339da..e89b914227 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2665,13 +2665,14 @@ QByteArray QMetaEnum::valueToKeys(int value) const
int count = mobj->d.data[handle + 2];
int data = mobj->d.data[handle + 3];
int v = value;
- for(int i = 0; i < count; i++) {
+ // reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first.
+ for (int i = count - 1; i >= 0; --i) {
int k = mobj->d.data[data + 2*i + 1];
if ((k != 0 && (v & k) == k ) || (k == value)) {
v = v & ~k;
if (!keys.isEmpty())
- keys += '|';
- keys += stringData(mobj, mobj->d.data[data + 2*i]);
+ keys.prepend('|');
+ keys.prepend(stringData(mobj, mobj->d.data[data + 2*i]));
}
}
return keys;