Results 1 to 11 of 11

Thread: canonicalFilePath() thread problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: canonicalFilePath() thread problems

    I was able to reproduce the problem with a single main.cpp (below). I reported to Trolltech, but feel free to try it out on your system. I am using Windows XP.

    Qt Code:
    1. #include <QtGui>
    2. #include <QDir>
    3.  
    4. ///Change these as needed
    5. #define SAMPLE_DIRECTORY_1 "c:\\"
    6. #define SAMPLE_DIRECTORY_2 "c:\\jer"
    7. #define NUM_REPEATS 100
    8. ///When DO_LOCK_MUTEX is turned off, inconsistencies are displayed on my system
    9. //#define DO_LOCK_MUTEX
    10.  
    11. static QMutex my_mutex;
    12.  
    13. class MyThread1 : public QThread
    14. {
    15. public:
    16. void run()
    17. {
    18. QString dirname=SAMPLE_DIRECTORY_1;
    19. QDir dir(dirname);
    20. QStringList list=dir.entryList(QStringList("*"));
    21. for (int j=0; j<NUM_REPEATS; j++) {
    22. foreach (QString F,list) {
    23. #ifdef DO_LOCK_MUTEX
    24. my_mutex.lock();
    25. #endif
    26. QString path=dirname+"/"+F;
    27. QString str1=QFileInfo(path).canonicalFilePath();
    28. QString str2=QFileInfo(path).canonicalFilePath();
    29. if (str1!=str2) {
    30. qDebug() << "~!!!!!!!!!!!!!!!!! Inconsistency with" << str1 << str2;
    31. }
    32. #ifdef DO_LOCK_MUTEX
    33. my_mutex.unlock();
    34. #endif
    35. }
    36. }
    37. }
    38. };
    39.  
    40. class MyThread2 : public QThread
    41. {
    42. public:
    43. void run()
    44. {
    45. QString dirname=SAMPLE_DIRECTORY_2;
    46. QDir dir(dirname);
    47. QStringList list=dir.entryList(QStringList("*"));
    48. for (int j=0; j<NUM_REPEATS; j++) {
    49. foreach (QString F,list) {
    50. #ifdef DO_LOCK_MUTEX
    51. my_mutex.lock();
    52. #endif
    53. QString path=dirname+"/"+F;
    54. QString str1=QFileInfo(path).canonicalFilePath();
    55. QString str2=QFileInfo(path).canonicalFilePath();
    56. if (str1!=str2) {
    57. qDebug() << "~!!!!!!!!!!!!!!!!! Inconsistency with" << str1 << str2;
    58. }
    59. #ifdef DO_LOCK_MUTEX
    60. my_mutex.unlock();
    61. #endif
    62. }
    63. }
    64. }
    65. };
    66.  
    67.  
    68.  
    69.  
    70.  
    71. int main(int argc, char **argv)
    72. {
    73. QApplication app(argc, argv);
    74. QWidget wid;
    75. wid.show();
    76. MyThread1 T1;
    77. MyThread2 T2;
    78. T1.start();
    79. T2.start();
    80.  
    81. qDebug() << "Looking for inconsistencies in QFileInfo::canonicalFilePath()";
    82.  
    83.  
    84. return app.exec();
    85. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: canonicalFilePath() thread problems

    For information, trolls have acknowledged the problem and are now working on it.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Replies: 10
    Last Post: 20th March 2007, 22:19
  3. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. Problems with threads and windows
    By SkripT in forum Qt Programming
    Replies: 15
    Last Post: 16th January 2006, 17:46

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
  •  
Qt is a trademark of The Qt Company.