PDA

View Full Version : QSettings + GDB = crash



codeslicer
19th December 2010, 15:34
Hi, I'm in a bit of a conundrum: using QSettings results in a crash under Windows XP, MinGW, Qt 4.7.




#include <QtCore/QCoreApplication>
#include <QtCore/QSettings>


int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "C:/folder");

QSettings s("Org", "App");
s.setValue("test", "value");

return a.exec();
}


This simple app throws an exception at line 9, ultimately pointing to some code in qsettings.cpp:


if (SHGetSpecialFolderPath) {
wchar_t path[MAX_PATH];
SHGetSpecialFolderPath(0, path, type, FALSE);
result = QString::fromWCharArray(path);
}

At other times, creating a pointer to a QSettings object in the header file and later initializing it results in the same exception:


// header of some class
QSettings *mySettings;

...

// constructor of class
mySettings = new QSettings();


This doesn't happen on Windows, and the app runs fine when I don't use a debugger. I found a reported bug on http://bugreports.qt.nokia.com/browse/QTBUG-14906?page=com.atlassian.jira.plugin.system.issuet abpanels:all-tabpanel but it doesn't seem to be verified.