When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?
-
When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?
-
When terminating a Qthread that is in QwaitCondition, a Qt application crashes. Anyone have a solution?
@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.
-
@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-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.
@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.
-
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();
} -
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.
-
it is not actual code, I just try to explain it to you by writing dummy code.
-
it is not actual code, I just try to explain it to you by writing dummy code.
@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.
-
can you give me an answer when the Qthread is in wait condition and somehow the thread is terminated what happens?
-
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.