Results 1 to 2 of 2

Thread: Stop the thread during recursivly loading directory

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Stop the thread during recursivly loading directory

    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:irView(QString strPath)
    {
    //recursivly loading directory
    }

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stop the thread during recursivly loading directory

    Qt Code:
    1. void QDirThread:dirView(QString strPath)
    2. {
    3. //recursivly loading directory
    4. }
    To copy to clipboard, switch view to plain text mode 
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.