QThread: Destroyed while thread is still running



  • Hi !
    I have a small problem.
    This is my code :

    MainWindow.cpp
    @
    bool m_abort;

    Thread::Thread()
    {
    }

    void Thread::run()
    {
    while(m_abort){
    // ...
    }

    exec();
    }

    MainWindow::MainWindow()
    {
    // .....

    m_threadSend = new Thread;
    m_abort=true;
    m_threadSend->start();

    // .....
    }

    MainWindow::~MainWindow()
    {
    m_abort=false;
    m_threadSend->wait();
    delete m_threadSend;

    // ...
    }
    @

    When I run then exit the application I get this message in the terminal :

    QThread: Destroyed while thread is still running

    Where is the Error ?



  • Just remove exec(); call from Thread::run() implementation.


Log in to reply
 

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