And I will answer myself. One needs to use d.putItem instead of d.putValue and then all works like a charm.
______________________________________________________________
> Od: resurrection at centrum.cz
> Komu: "André Pönitz" <apoenitz at t-online.de>, qt-creator at qt-project.org
> Datum: 12.05.2019 17:05
> Předmět: Re: [Qt-creator] Debugging helper for forward declared classes (PIMPL)
>
Thanks, this works!
I have only one problem with this. When the type of a field is another complex type for which a debugging helper exists (e.g. QString) instead of using that helper for that type it puts there the Python object representation, e.g.:
def qdump__MyType(d, value):
address = d.extractPointer(value["d"])
ptr = d.createValue(address, "void*")
name = ptr.split("{QString}")
with Children(d):
with SubItem(d, "Name"):
d.putName("Name")
d.putValue(name)
The value that appears during debugging is:
Value(name='None',type=QString,bsize=None,bpos=None,data=40E3A8DBFE7F0000,address=0x23f1f3888d0)
I can work around this by copying the logic from the particular debugging helper (mine or Qt's) but I would expect it to be picked up automatically or that I could somehow call it myself. I must be missing something yet.
______________________________________________________________
> Od: "André Pönitz" <apoenitz at t-online.de>
> Komu: resurrection at centrum.cz
> Datum: 12.05.2019 13:50
> Předmět: Re: [Qt-creator] Debugging helper for forward declared classes (PIMPL)
>
On Sun, May 12, 2019 at 12:42:33PM +0200, resurrection at centrum.cz wrote:
> I have a problem creating a debugging helper for classes that does use only
> forward-declared data member like when using PIMPL:
> - MyClass.h
> struct MyClassPrivate;
> class MyClass
> {
> MyClassPrivate *d;
> };
>
> - MyClass.cpp
> struct MyClassPrivate
> {
> int i;
> };
> //...
>
> And the debugging helper:
>
> def qdump__MyClass(d, value):
> with Children(d):
> d.putSubItem("Number", value["d"]["i"])
>
> Only place when debugging helper for MyClass works is in the implementation file of
> MyClass.cpp. In all other places the MyClassPrivate is just forward declared type and
> the pointer to it is completely opaque to the debugging helper engine unless I step into
> the MyClass.cpp where the type is defined. I may be asking for the impossible, but is
> there a way to work around this somehow?
When you know the layout of the private class, you can direcly operate on that.
E.g. value.split('...') e.g. works similar to Python's struct.unpack('...')
I actually prefer this approach nowadays for rarely changing types as it does
not require any debug information for the type, just the address of an instance.
Andre'