Sunday, July 19, 2009

Debugging Helpers typedef Bug

Debugging helpers are great. They show you the contents of common Qt types such as maps, lists and strings and are invaluble when debugging code. However, a bug exists that means if you typedef a QMap, QList, etc. then the debugging helper won't work. Take the following example:

#include <QtCore/QCoreApplication>
#include <QMap>

#include <QString>

#include <QListv


int main(int argc, char *argv[])

{

QCoreApplication a(argc, argv);

QMap<QString, QString> map1;

map1["Hello"] = "World!";


typedef QMap<QString, QString> Map;

Map map2;

map2["Hello"] = "World!";


QList<int> list1;

list1.append(1234);


typedef <int> List;

List list2;

list2.append(1234);

return a.exec();

}


If you stick a breakpoint on the last line the debugger happily displays the contents of map1 and list1, but not map2 and list2 as they have been declared using the typedef. Now, I use the typedef keyword a lot, so this is a PITA, but it's been reported so I'm sure a fix is in the works.


No comments:

Post a Comment