PDA

View Full Version : Stop the thread during recursivly loading directory



santosh.kumar
14th May 2007, 11:44
hi

i m writing code like...
but it is not working properly..where i have done mistake
in Run() method ,any loop ...and my thread is not stopping...
give me correct suggestions...


QDirThread:: QDirThread(QObject*parent):QThread(parent)
{
m_bAbort = false;
}
QDirThread::~ QDirThread()
{
m_bAbort = true;
}
void QDirThread::run()
{
if(!m_bAbort)
{
DirView(strPath);
}
else
return;
}
void QDirThread::dirViewSleep()
{
usleep(25000);
}
void QDirThread::stop()
{
m_bAbort = true;
}
void QDirThread::DirView(QString strPath)
{
//recursivly loading directory
}

marcel
14th May 2007, 19:02
void QDirThread:dirView(QString strPath)
{
//recursivly loading directory
}

Since you say recursively, I assume you call dirView inside for each dir. All you have to do is test m_bAbort is true before calling dirView ( inside dirView ).
Also, when you parse the files inside the current dir ( which you most likely do in a loop ), you must test for m_bAbort.

Regards