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

QSettings::sync() fails with AccessError

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.10.0
    • Core: I/O
    • None
    • Windows 10, MinGW 5.3 (x32)

    Description

      QSettings::sync() sets AccessError, when working with QTemporaryFile.

      Example test case:

      void TestTempSettings()
      {
          QTemporaryFile temp("temp_settings_XXXXXX.ini");
          if (temp.open())
          {
              temp.close();
              qDebug() << "Temp file is closed: " << !temp.isOpen();
      
              QSettings tempSets(temp.fileName(), QSettings::IniFormat);
              tempSets.setValue("TestValue", "test");
              qDebug() << "Value set status: " << tempSets.status();
      
              tempSets.sync();
              qDebug() << "QSettings sync status:" << tempSets.status();
          }
          else
          {
              qDebug() << "Failed to open temp file" << temp.errorString();
          }
      }
      
      int main(int argc, char *argv[])
      {
          Q_UNUSED(argc)
          Q_UNUSED(argv)
      
          TestTempSettings();
      }
      

      Output:  

      Temp file is closed: true
      Value set status: QSettings::Status(NoError)
      QSettings sync status: QSettings::Status(AccessError)
      

      Nothing is actually written to temporary file, though it seems to be closed and write-ready. Same code worked seamlessly at least with Qt 5.3.

      General QFile was able to write to temporary file without errors. 

       

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            v0l0dia Vladimir Bondarenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes