Qt Forum - programming with C++ and Qt
Register Calendar Members List Team Members Search Frequently Asked Questions Go to the Main Page

Qt Forum - programming with C++ and Qt » QtForum.org » Qt » Qt Programming » qthread deleted while still running » Hello Guest [Login|Register]
Last Post | First Unread Post Print Page | Recommend to a Friend | Add Thread to Favorites
Post New Thread Post Reply
Go to the bottom of this page qthread deleted while still running
Author
Post « Previous Thread | Next Thread »
itachi86 itachi86 is a male
Coder


Registration Date: 24.04.2008
Posts: 21
Location: Paris

Level: 8 [?]
Experience: 471
Next Level: 674

203 points of experience needed for next level

verrückt qthread deleted while still running Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

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.

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


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:
#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


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:
44:
45:
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();
}


code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
#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.
09.05.2008 21:12 itachi86 is offline Send an Email to itachi86 Search for Posts by itachi86 Add itachi86 to your Buddy List YIM Account Name of itachi86: informatiquei2rv@yahoo.fr View the MSN Profile for itachi86
Nicolas SOUCHON
Wizard


Registration Date: 27.06.2007
Posts: 726

Level: 29 [?]
Experience: 235,500
Next Level: 242,754

7,254 points of experience needed for next level

RE: qthread deleted while still running Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

avoid
this->exit();
in yourThread::run()

__________________
Nicolas
09.05.2008 21:52 Nicolas SOUCHON is online Send an Email to Nicolas SOUCHON Search for Posts by Nicolas SOUCHON Add Nicolas SOUCHON to your Buddy List
itachi86 itachi86 is a male
Coder


Registration Date: 24.04.2008
Posts: 21
Location: Paris

Level: 8 [?]
Experience: 471
Next Level: 674

203 points of experience needed for next level

Thread Starter Thread Started by itachi86
Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

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.
09.05.2008 23:11 itachi86 is offline Send an Email to itachi86 Search for Posts by itachi86 Add itachi86 to your Buddy List YIM Account Name of itachi86: informatiquei2rv@yahoo.fr View the MSN Profile for itachi86
Nicolas SOUCHON
Wizard


Registration Date: 27.06.2007
Posts: 726

Level: 29 [?]
Experience: 235,500
Next Level: 242,754

7,254 points of experience needed for next level

Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

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
10.05.2008 09:45 Nicolas SOUCHON is online Send an Email to Nicolas SOUCHON Search for Posts by Nicolas SOUCHON Add Nicolas SOUCHON to your Buddy List
itachi86 itachi86 is a male
Coder


Registration Date: 24.04.2008
Posts: 21
Location: Paris

Level: 8 [?]
Experience: 471
Next Level: 674

203 points of experience needed for next level

Thread Starter Thread Started by itachi86
Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

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 time(s), it was last edited by itachi86: 10.05.2008 12:12.

10.05.2008 11:49 itachi86 is offline Send an Email to itachi86 Search for Posts by itachi86 Add itachi86 to your Buddy List YIM Account Name of itachi86: informatiquei2rv@yahoo.fr View the MSN Profile for itachi86
itachi86 itachi86 is a male
Coder


Registration Date: 24.04.2008
Posts: 21
Location: Paris

Level: 8 [?]
Experience: 471
Next Level: 674

203 points of experience needed for next level

Thread Starter Thread Started by itachi86
Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

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.
10.05.2008 21:34 itachi86 is offline Send an Email to itachi86 Search for Posts by itachi86 Add itachi86 to your Buddy List YIM Account Name of itachi86: informatiquei2rv@yahoo.fr View the MSN Profile for itachi86
Tree Structure | Board Structure
Jump to:
Post New Thread Post Reply
Qt Forum - programming with C++ and Qt » QtForum.org » Qt » Qt Programming » qthread deleted while still running

views today: 9.811 | views yesterday: 17.520 | total views: 10.243.180


Klebekork Shop - Linux Shop - Kontaktanzeigen - Linux Forum -  SMS Gewinnspiel -  Hotels -  Stadtpläne -  Branchenbuch & Stadtplan

Branchenbuch Österreich - Branchenbuch Niederlande - Portugal Branchenverzeichnis - Spanien Branchenverzeichnis 
Telefonbuch - Branchenbuch Frankreich