Results 1 to 2 of 2

Thread: What is safest way of force terminating a QThread without QThread::terminate()

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default What is safest way of force terminating a QThread without QThread::terminate()

    Hi guys, what is the safest way of force terminating a thread without using the function QThread::terminate(). The documentation says this functions is dangerous and should be avoided, so what is the work around this, if I want to force terminate the thread while its still running some operation?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: What is safest way of force terminating a QThread without QThread::terminate()

    One way would be to add a flag to your thread that it monitors, once the flag is set, you can have your thread terminate gracefully, cleaning up after it self.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 11
    Last Post: 16th May 2012, 09:40
  2. terminate a QThread from GUI
    By OverTheOCean in forum Qt Programming
    Replies: 6
    Last Post: 26th July 2010, 03:12
  3. Terminate a QThread with an event loop
    By paolom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 12:53
  4. QThread::terminate () is not working!!!!!
    By biswajithit in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2008, 13:03
  5. Terminating QThread error
    By ramazangirgin in forum Qt Programming
    Replies: 9
    Last Post: 24th August 2008, 19:18

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.