Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QThread: Destroyed while thread is still running
Qt 6.11 is out! See what's new in the release blog

QThread: Destroyed while thread is still running

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    issam
    wrote on last edited by
    #1

    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 ?

    http://www.iissam.com/

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DKvita
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved