Saturday, July 5th 2008, 6:01am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

itachi86

Beginner

Posts: 25

Location: Paris

Occupation: studdent

1

Friday, May 9th 2008, 8:12pm

qthread deleted while still running

Hye,

I'm a little bit lost.
I have a problem about thread => QThread: Destroyed while thread is still running
Moreover, I can't say why but if I comment f) and g) the error disappeares.

Source code

1
2
3
finalCountDown countDown(numYear,numMonth,numDay,70);
countDown.start();
countDown.wait();


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#define FINALCOUNTDOWN_H

#include <QThread>
#include <QVector>
#include "figure.h"

class finalCountDown : public QThread
{
private : 
	int numYear;
	int numMonth;
	int numDay;
	int lifeExpectancy;
	int dayAmount;
	int hourAmount;
	int minuteAmount;
	int secondAmount;
public:
	finalCountDown(int,int,int,int);
	void run();
	
};

#endif


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
finalCountDown :: finalCountDown(int _numYear,int _numMonth,int _numDay,int _lifeExpectancy)
{
	this->numYear =_numYear;
	this->numMonth = _numMonth;
	this->numDay = _numDay;
	this->lifeExpectancy = _lifeExpectancy;
}

void finalCountDown :: run()
{
	QDateTime now(QDate(numYear,numMonth,numDay),QTime(0,0));
	QDateTime toDeath (QDate(numYear+lifeExpectancy,numMonth,numDay),QTime(0,0));
	long calculateSec = (long)toDeath.secsTo(now);
	long calculateMin = (calculateSec%86400)%3600/60;
	long calculateHour = (calculateSec%86400)/3600;
	long calculateDay = calculateSec/86400 ;
	long seconde = calculateSec%86400%3600%60;
	figure secondAmount(seconde);
	figure minuteAmount(calculateMin);
	figure hourAmount(calculateHour);
	figure dayAmount(calculateDay);
	
	qDebug("calculateSec : %ld",seconde);
	qDebug("calculateMin : %ld",calculateMin);
	qDebug("calculateHour : %ld",calculateHour);
	qDebug("calculateDay : %ld",calculateDay);
	QVector<figure> countDown = secondAmount.toVector();
	QVector<figure> minuteInVector = minuteAmount.toVector();
	f)QVector<figure> hourInVector = hourAmount.toVector();
	g)QVector<figure> dayInVector = dayAmount.toVector();
	
	
	qDebug("Convertion done ");
	int i = 0;
	while(i<5)
	{
		qDebug("Debug %d",i);
		i++;
		sleep(1);
		
	}
	this->exit();
}


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef FIGURE_H
#define FIGURE_H

#include <QVector>

class figure
{
	public :
		long nb;
		figure();
		figure(long);
		long getNb();
		long operator+(int);
		long operator-(int);
		QVector<figure> toVector();
		QVector<figure> meltVector(QVector<figure>,QVector<figure>);
};
Dude : You have a banana in your ear!!!
John Doe : WHAT?!?
Dude : YOU HAVE A BANANA IN YOU EAR
John Doe : I CAN'T HEAR YOU I HAVE A BANANA IN MY EAR.
  • Go to the top of the page

2

Friday, May 9th 2008, 8:52pm

RE: qthread deleted while still running

avoid
this->exit();
in yourThread::run()
Nicolas
  • Go to the top of the page

itachi86

Beginner

Posts: 25

Location: Paris

Occupation: studdent

3

Friday, May 9th 2008, 10:11pm

ok I thinks this exit will resolve my problem but unfortunately it didn't.

Anyone can't told me why I have this kind of error.
Dude : You have a banana in your ear!!!
John Doe : WHAT?!?
Dude : YOU HAVE A BANANA IN YOU EAR
John Doe : I CAN'T HEAR YOU I HAVE A BANANA IN MY EAR.
  • Go to the top of the page

4

Saturday, May 10th 2008, 8:45am

probably the problem is not in your QThread class
without code showing how your threads are created and managed,
difficult to help you
do you use QThread::terminate()?
Nicolas
  • Go to the top of the page

itachi86

Beginner

Posts: 25

Location: Paris

Occupation: studdent

5

Saturday, May 10th 2008, 10:49am

In fact no I don't use terminate().

May be it's the solution. I'll try.

As for the code, it's just the first post of the thread(sorry I forgot to explain toVector. In fact, it takes a long number and create a vector in which there is each figure of the long number).
Dude : You have a banana in your ear!!!
John Doe : WHAT?!?
Dude : YOU HAVE A BANANA IN YOU EAR
John Doe : I CAN'T HEAR YOU I HAVE A BANANA IN MY EAR.

This post has been edited 1 times, last edit by "itachi86" (May 10th 2008, 11:12am)

  • Go to the top of the page

itachi86

Beginner

Posts: 25

Location: Paris

Occupation: studdent

6

Saturday, May 10th 2008, 8:34pm

Ok I got it!!!

My problem was in this function toVector()
Dude : You have a banana in your ear!!!
John Doe : WHAT?!?
Dude : YOU HAVE A BANANA IN YOU EAR
John Doe : I CAN'T HEAR YOU I HAVE A BANANA IN MY EAR.
  • Go to the top of the page

Rate this thread