Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-133758

QTemporaryDir does not remove directory upon destruction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15.12
    • Core: Other
    • None
    • Windows 10
      Linux Yocto Kirkstone running on iMX.6
    • Linux/Yocto, Windows

      https://doc.qt.io/qt-5/qtemporarydir.html#details says that as soon as the scope where the QTemporaryDir was created is left, the directory gets removed if autoRemove is set to true.

      However, it seems that directories are not automatically removed upon destruction of the object.

      • Created directory is valid and created
      • AutoRemove flag is set to true (checked via your class' method)
      • Tested with empty directories and ones that have a file in them
      • Directories also not destructed after clean shutdown/reboot of the application (and also of the system itself)
      • Tested with absolute paths and default temp ones
      • manual call to remove, removes the directory successfully

       

      Pseudo code-snippet:

      const auto dir= new QTemporaryDir("/my/path");
        if(dir->isValid())
        {
          if(!dir->remove())
         
      
      {       const auto negIndicator= new QTemporaryDir("/my/path/failed");     }
      
          else{
            const auto posIndicator = new QTemporaryDir("/my/path/success");
            if(posIndicator->isValid())
            {
              QString path = posIndicator->path();
              QFile file(path + "/myFile.txt");
              if(file.open(QFile::WriteOnly | QFile::Truncate))     
      
              {
      
                QTextStream stream(&file);           stream << "something" << (dir->autoRemove() ? " true" : " false") << (posIndicator->autoRemove() ? " true" : " false") << "/n";
      
              }
      
            }
          }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            thiago Thiago Macieira
            pcm_dolo Dominic Loosli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes