Results 1 to 6 of 6

Thread: Release mode issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Posts
    14
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Release mode issue

    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.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Release mode issue

    Just clean build the application and make sure you are using correct version of release mode dlls when running in the release mode
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Replies: 1
    Last Post: 7th March 2012, 21:34
  2. Replies: 1
    Last Post: 2nd November 2009, 12:02
  3. Replies: 9
    Last Post: 15th April 2009, 06:23
  4. Replies: 8
    Last Post: 10th October 2007, 18:20
  5. Release mode issue
    By stevey in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2006, 20:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.