Hi

I have an application that builds and runs fine in Debug mode, but when ran in Release mode it produces a "Access violation reading location 0x...." error. I try to process the command line parameters passed to the application before constructing the QMainWindow and calling QApplication.exec(). I have put some qDebug() statements and it appears it crashes straight after I call any QString methods. It appears to me that there might be some linking errors but I can't seem to find the cause. Here's my main() function:

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4. MyWindow *mw= 0;
  5. QString s = QString("myHardCodedString").toLower().trimmed();
  6. qDebug() << s;
  7. if(a.argc() > 1)
  8. {
  9. qDebug() <<"before check";
  10. QString correctStr = MyHelper::getProgramStr();
  11. qDebug() <<"str: " << correctStr;
  12.  
  13. qDebug() << a.arguments();
  14. qDebug() << a.arguments().at(1);
  15.  
  16. QString res = a.arguments().at(1).toLower().trimmed();
  17. qDebug() << "arg: " << res;
  18.  
  19. //code below never reached in Release mode
  20. //..........
  21. }
  22. else
  23. {
  24. QErrorMessage *error = new QErrorMessage();
  25. //set errormessage
  26. //.........
  27. }
  28.  
  29. return a.exec();
  30. }
To copy to clipboard, switch view to plain text mode 

The last qDebug() message before the "Access violation" error in release mode is this one:
Qt Code:
  1. qDebug() << a.arguments().at(1);
To copy to clipboard, switch view to plain text mode 

A note: I put the "myHardCodedString" string just to test if the problem was caused by QString methods. Before I put that in, the error surfaced later on in the main function, but with it there, the error occurred right after the stated qDebug() line and before the next one.

I am using Qt 4.8.3 on Windows 7 x64 and VisualStudio 2010.

Hope that's enough information and thanks in advance.