3
votes

I use QtCreator 3 with Qt 5.2 and the VS2012 compiler, CDB debugger from windows debugging tools. While debugging a program (debug build), I noticed that the values shown in the debugger are sometimes wrong. I can reproduce the problem on the following minimal example:

#include <QList>
#include <QDebug>

struct SubPart
{
    unsigned short v1, v2, v3;
};

struct Part
{
    void appendSubPart(unsigned short v1, unsigned short v2, unsigned short v3)
    {
        SubPart newSubPart;
        newSubPart.v1 = v1;
        newSubPart.v2 = v2;
        newSubPart.v3 = v3;
        subParts_ << newSubPart;
    }

    QList<SubPart> subParts_;
};

int main(int argc, char *argv[])
{
    Part part;
    part.appendSubPart(1, 2, 3);
    part.appendSubPart(3, 4, 5);

    SubPart &ref(part.subParts_[0]);

    // Debug print the content of part.subParts_
    for ( auto &i : part.subParts_ ) {
        qDebug() << i.v1 << i.v2 << i.v3;
    }

    return 0;
}

Program output is (as expected):

1 2 3
3 4 5

But debugger shows:

Debugger screenshot

The debugger view of the QList part.subParts_ is garbage. The reference ref to an element in the list fine.

Anyone know what's going on here?

1
Exactly where is your breakpoint? At the line of the comment?otisonoza
The breakpoint for the screenshot was on the line return 0;, but it shows the same if the breakpoint is on the line for ( auto &i : part.subParts_ ) {jcm
Also, it's C#, but related to VS: stackoverflow.com/questions/18126642/…otisonoza
Thanks for the links. I think the issues in the links are unrelated (it's mostly about CLR stuff). Here it looks like the problem is in the data formatter for the Qt data types.jcm

1 Answers

0
votes

Updating Qt Creator to version 3.0.1 and Qt to version 5.2.1 solved the problem. The debug view of the QList shows the correct values.