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. When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?
QtWS25 Last Chance

When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 583 Views
  • 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.
  • S Offline
    S Offline
    sandip.nandwana
    wrote on last edited by
    #1

    When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?

    Christian EhrlicherC 1 Reply Last reply
    0
    • S sandip.nandwana

      When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sandip-nandwana said in When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?:

      Anyone have a solution?

      Provide a minimal, compilable example because you do something wrong.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sandip.nandwana
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?:

        Provide a minimal, compilable example because you do something wrong.

        the Qthread is in QwaitCondition.wait( &m_TaskMutex ) and I try to terminate the thread and the result is Application get crashes.

        Christian EhrlicherC 1 Reply Last reply
        0
        • S sandip.nandwana

          @Christian-Ehrlicher said in When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?:

          Provide a minimal, compilable example because you do something wrong.

          the Qthread is in QwaitCondition.wait( &m_TaskMutex ) and I try to terminate the thread and the result is Application get crashes.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sandip-nandwana said in When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?:

          the Qthread is in QwaitCondition.wait( &m_TaskMutex ) and I try to terminate the thread and the result is Application get crashes.

          You still do not provide any code so we can reproduce the issue. You're for sure doing something wrong but we can't help until you tell us what you're doing.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sandip.nandwana
            wrote on last edited by sandip.nandwana
            #5

            I have
            Run(){
            while(1)
            {
            if(queue.isEmpty() ){
            m_TaskMutex.lock();
            QwaitCondition.wait( &m_TaskMutex ) ;
            m_TaskMutex.unlock();
            }
            else
            {
            //Do some work
            }
            }
            }

            and I have another public function in which I am trying to terminate the Qthread.

            void terminatethread()
            {
            this->terminate();
            }

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              This is no minimal,compilable example. Also a 'while(1)' is bad coding style - change it.

              And also annotate your code with proper <code> - tags so others can read it.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sandip.nandwana
                wrote on last edited by
                #7

                it is not actual code, I just try to explain it to you by writing dummy code.

                Christian EhrlicherC 1 Reply Last reply
                0
                • S sandip.nandwana

                  it is not actual code, I just try to explain it to you by writing dummy code.

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @sandip-nandwana said in When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?:

                  you by writing dummy code.

                  This does not help, esp. since your code never can go out of your endless loop.

                  Again: provide a minimal, compilable example of your crashing code. Everything else will not work out; esp. not some dummy code which doesn't even compile and has serious design flawas from the beginning.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sandip.nandwana
                    wrote on last edited by
                    #9

                    can you give me an answer when the Qthread is in wait condition and somehow the thread is terminated what happens?

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      can you give me an answer when the Qthread is in wait condition and somehow the thread is terminated what happens?

                      it may eat kittens.

                      Don't use a waiting infinite loop, properly interrupt() your thread and then wait() for it's deletion.

                      Or even better - don't use thread at all - it's not needed in most of the use-cases here.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1

                      • Login

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