Crash in debug but not in release

  • I have made some function in my code like this method:

     MyMessageBox m(this);
        m.setText(tr("Chargement des goupilles..."));
        QPixmap p(":/icones/wait");
        QMovie *mov = new QMovie(":/gif/wait");
        m.setObjectName("Mon message d'attente");
        //BUG: PROBLEME ICI plantage en mode debug
        QtConcurrent::run(this, SelectGoupRef::runFindPins, &m);

    The current class is QDialog(this)
    I create a messageBox to show a waiting state for the user, the runFindPins is the process and when the computation is done, is say "accept" to MyMessageBox (m.accept();).

    In Release mode all work fine but in Debug my app crash ???

  • Moderators

    You should NEVER manipulate UI from a different thread!
    This is not supported. Instead you should emit a signal from the thread which is connected to a slot in main thread which closes the message box (use Qt::QueuedConnection in connect(...)).

  • You have right I change with:=>

    QFutureWatcher<void> watcher;
        connect(&watcher, SIGNAL(finished()), &m, SLOT(accept()));
        watcher.setFuture(QtConcurrent::run(this, &SelectGoupRef::runFindPins, &watcher));

    And no problem in debug.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.