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

        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