MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / to_string

Method to_string

src/scripts/prettyprinters/qt.py:20–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

18 self.val = val
19
20 def to_string(self):
21 ret = ""
22
23 # The QString object may not be initialized yet. In this case 'size' is a bogus value
24 # or in case of Qt5, 'd' is an invalid pointer and the following lines might throw memory
25 # access error. Hence the try/catch.
26 try:
27 size = self.val['d']['size']
28 if size == 0 or size >= 50000: #refer to QtCreator : limit 100000
29 return ret
30 isQt4 = has_field(self.val['d'], 'data') # Qt4 has d->data, Qt5 doesn't.
31 isQt6 = has_field(self.val['d'], 'ptr') # Qt6 has d->ptr, Qt5 doesn't.
32 if isQt4:
33 dataAsCharPointer = self.val['d']['data'].cast(gdb.lookup_type("char").pointer())
34 elif isQt6:
35 dataAsCharPointer = self.val['d']['ptr'].cast(gdb.lookup_type("char").pointer())
36 else:
37 dataAsCharPointer = (self.val['d'] + 1).cast(gdb.lookup_type("char").pointer())
38 ret = dataAsCharPointer.string(encoding = 'UTF-16', length = size * 2)
39 except Exception:
40 # swallow the exception and return empty string
41 pass
42 return ret
43
44 def display_hint (self):
45 return 'string'

Callers

nothing calls this directly

Calls 2

has_fieldFunction · 0.85
stringMethod · 0.80

Tested by

no test coverage detected