Important: Please read the Qt Code of Conduct -

Strange behavior in Release mode but not in Debug mode

  • Hello,

    I have a strange problem that I'm stuck at the moment, when I run my application in Debug mode everything works perfectly fine, but when I just switch to Release mode there are some functions in my code that don't get called. One of these functions runs an executable with QProcess.

    Is there any reason why this might happen? I tried cleaning and rebuilding my project but had no luck.
    What can I do to fix something like this ?

    I am on Windows 7, using Qt 5.1 and QtCreator 2.8 if that helps..


  • Lifetime Qt Champion


    Without any code it's pretty much crystal ball debugging.

    Do you have maybe these functions called in an assert statement ?

  • Moderators

    or some uninitialized variables? In debug mode everything gets 0-initialized, in release you get random garbage.

    @SGaist - is crystal ball debugging something like "this method": ? :)

  • No, I have no assert methods. This is what I have:

    First I make my QProcess and connect a signal to a slot.
    m_process = new QProcess(this);
    connect(m_process, SIGNAL(finished(int)),
    this, SLOT(processDone()));

    A function called processFile() getscalled :
    Here I just set up the arguments and start my QProcess.
    void MyWidget::processFile()
    // Getting .exe file path
    QString mExe = QDir::currentPath() + "/untitled.exe";

    QStringList args;
    QString file1 = m_currentlySelectedListItem;
    QString file2 = m_lastItem;
    m_Process->start(mExe, args);
    // This is where it stops, it won't go further...
    qDebug() << "------------ END OF FUNCTION ------------ ";


    Since I connected the finished() signal of my QProcess to a slot in Debug mode the slot gets called and everything works fine. In release mode it stops there in the comment and the slot never gets called.
    What am I doing wrong ?

    Thanks for your help!

  • Lifetime Qt Champion

    [quote author="Chris Kawa" date="1378761865"]
    @SGaist - is crystal ball debugging something like "this method": ? :)[/quote]

    Almost, it depends whether you can contact the duck or not :)

  • Lifetime Qt Champion

    @QString mExe = QDir::currentPath() + "/untitled.exe"@

    Are you sure this path is correct in both build ? i.e. is it really untitled.exe in debug mode ?

Log in to reply