Fix QKeyEvent structure in the dumper script

The dumper script used to have outdated pattern that did not match
the current layout of QEvent and QKeyEvent classes
leading to random garbage being read.
Updated the the pattern and added some explanatory comments.

Fixes: QTCREATORBUG-31564
Change-Id: I767d73f134ed46494183494148cb23dfb8df5eb4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Andrii Semkiv
2024-09-19 10:55:36 +02:00
parent 2eb54a0778
commit 3eb3f6009a

View File

@@ -581,7 +581,26 @@ def qdump__QEvent(d, value):
with Children(d): with Children(d):
# Add a sub-item with the event type. # Add a sub-item with the event type.
with SubItem(d, '[type]'): with SubItem(d, '[type]'):
(vtable, privateD, t, flags) = value.split("pp{short}{short}") if d.qtVersionAtLeast(0x060000):
(
# QEvent fields (must be kept in sync with the definition in qcoreevent.h)
vtable, # virtual table pointer
t, # quint16 t
posted, # bool m_posted
spont, # bool m_spont
accept, # bool m_accept
unused, # bool m_unused
flags, # quint16 m_reserved:13, quint16 m_inputEvent:1
# + quint16 m_pointerEvent:1 + quint16 m_singlePointEvent:1
) = value.split("p{short}ccccH")
else:
(
# QEvent fields (must be kept in sync with the definition in qcoreevent.h)
vtable, # virtual table pointer
privateD, # QEventPrivate *d
t, # ushort t
flags, # ushort posted:1 + ushort spont:1 + ushort m_accept:1 + ushort reserved:13
) = value.split("pp{short}{short}")
event_type_name = d.qtNamespace() + "QEvent::Type" event_type_name = d.qtNamespace() + "QEvent::Type"
type_value = t.cast(event_type_name) type_value = t.cast(event_type_name)
d.putValue(type_value.displayEnum('0x%04x')) d.putValue(type_value.displayEnum('0x%04x'))
@@ -592,29 +611,49 @@ def qdump__QEvent(d, value):
def qdump__QKeyEvent(d, value): def qdump__QKeyEvent(d, value):
# QEvent fields if d.qtVersionAtLeast(0x060000):
# virtual table pointer (
# QEventPrivate *d; # QEvent fields (must be kept in sync with the definition in qcoreevent.h)
# ushort t; vtable, # virtual table pointer
# ushort posted : 1; t, # quint16 t
# ushort spont : 1; posted, # bool m_posted
# ushort m_accept : 1; spont, # bool m_spont
# ushort reserved : 13; accept, # bool m_accept
# QInputEvent fields unused, # bool m_unused
# Qt::KeyboardModifiers modState; qevent_flags, # quint16 m_reserved:13, quint16 m_inputEvent:1
# ulong ts; # + quint16 m_pointerEvent:1 + quint16 m_singlePointEvent:1
# QKeyEvent fields # QInputEvent fields (must be kept in sync with the definition in qevent.h)
# QString txt; dev, # const QInputDevice *m_dev
# int k; ts, # quint64 m_timeStamp
# quint32 nScanCode; modState, # Qt::KeyboardModifiers modState
# quint32 nVirtualKey; reserved, # quint32 m_reserved
# quint32 nModifiers; <- nativeModifiers # QKeyEvent fields (must be kept in sync with the definition in qevent.h)
# ushort c; txt, # QString m_text
# ushort autor:1; k, # int m_key; (actually a Qt::Key in disguise)
# ushort reserved:15; scanCode, # quint32 m_scanCode
(vtable, privateD, t, flags, modState, ts, txt, k, scanCode, virtualKey, # quint32 m_virtualKey
virtualKey, modifiers, modifiers, # quint32 m_nativeModifiers
c, autor) = value.split("ppHHiQ{@QString}{int}IIIHH") qkeyevent_flags # quint16 m_count:15 + quint16 m_autoRepeat:1
) = value.split("pHccccHpQiI{@QString}{int}IIIH")
else:
(
# QEvent fields (must be kept in sync with the definition in qcoreevent.h)
vtable, # virtual table pointer
privateD, # QEventPrivate *d
t, # ushort t
flags, # ushort posted:1 + ushort spont:1 + ushort m_accept:1 + ushort reserved:13
# QInputEvent fields (must be kept in sync with the definition in qevent.h)
modState, # Qt::KeyboardModifiers modState
ts, # ulong ts
# QKeyEvent fields (must be kept in sync with the definition in qevent.h)
txt, # QString txt
k, # int k
scanCode, # quint32 nScanCode
virtualKey, # quint32 nVirtualKey
modifiers, # quint32 nModifiers
c, # ushort c
autor # ushort author:1
) = value.split("ppHHiQ{@QString}{int}IIIHH")
#d.putStringValue(txt) #d.putStringValue(txt)
#data = d.encodeString(txt) #data = d.encodeString(txt)