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

Randomly getting "Access is denied" error when saving files with QSaveFile.

    XMLWordPrintable

Details

    • Windows
    • 9d8e23328 (dev), 164363e18 (6.7)
    • Foundation Sprint 105

    Description

      Randomly getting "Access is denied" error  when saving files with QSaveFile.

      To reproduce the issue:

      • Create " LYNX " folder in the following path C:\Users\<YourUserName>\Documents\
      • Set the proper value of "user" variable in the code below.
      • Build and run the following code:
        #include <QSaveFile>
        #include <QDebug>
        void test(QString username){
            qInfo() << "running qsavefile test";
            const auto filePath = "C:/Users/" + username + "/Documents/LYNX/qsavefile-test.lynx";
            for (int i = 0; i < 10000; i++) {
                QByteArray data(4, 'd');
                QSaveFile file(filePath);
                if (!file.open(QIODevice::WriteOnly)) {
                    qCritical() << "qsavefile open failed: " << i << ": " << file.errorString();
                    return;
                }
                file.write(data);
                if (!file.commit()) {
                    qCritical() << "qsavefile commit failed: " << i << ": " << file.error() << ": " << file.errorString();
                    return;
                }
                qDebug() << "pass" ;
            }
            qInfo() << "test complete";
        
        }
        
        int main(int argc, char *argv[])
        {
            QString user = "" ;// set YourUserName
            test(user);
            return 0;
        }
        

      Note: the number of iterations varies with each run.

       

      Attachments

        1. [5.15v2]-QSaveFile-win-Use-SetFileInformationByHandle-for-ato.patch
          5 kB
          Mårten Nordheim
        2. log.PML
          4.81 MB
          Jan Pradas
        3. screenshot-1.png
          21 kB
          Thiago Macieira

        Issue Links

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

          Activity

            People

              manordheim Mårten Nordheim
              mahdi.belila Mehdi Belila
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              4 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes