Skip to content

Commit

Permalink
QString and QByteArray render improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Kobzev committed May 18, 2024
1 parent 9c30fa9 commit 6f9fe35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions python/lldb/qt6renderer/qarraydatapointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def update(self):
self._values[self._num_data_fields] = size
self._bump_field_counter()

if size.GetValueAsSigned() <= 0:
return False

d_d = d.GetChildMemberWithName('d')

if d_d.GetValueAsUnsigned():
Expand Down
2 changes: 1 addition & 1 deletion python/lldb/qt6renderer/qbytearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def qbytearray_string_summary(valobj: SBValue):
return '""'

size = sb_size.GetValueAsSigned()
if not size:
if size <= 0:
return '""'

sb_raw = valobj.GetChildMemberWithName(QArrayDataPointerSynth.PROP_RAW_DATA)
Expand Down
9 changes: 7 additions & 2 deletions python/lldb/qt6renderer/qstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ def qstring_summary_no_quotes(valobj: SBValue) -> str:
return ''

size = sb_size.GetValueAsSigned()
if not size:
if size <= 0:
return ''

sb_raw = valobj.GetChildMemberWithName(QArrayDataPointerSynth.PROP_RAW_DATA)
if not sb_raw:
return ''

data = sb_raw.GetPointeeData(0, size).sint16s
# QString is char16_t in the C++ code.
# But Python goes wild when string bytes have higher order values, like 65533,
# because sint16 of such values get interpreted as negative numbers and Python
# is unable to convert them to chars.

data = sb_raw.GetPointeeData(0, size).uint16s

result = ''
for code in data:
Expand Down

0 comments on commit 6f9fe35

Please sign in to comment.