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

Static method QFile::rename() returns false

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.5.3
    • Core: I/O
    • None
    • Windows XP SP3
      Visual Studio 2005 (SP1)

    Description

      The static method QFile::rename() returns false if another QTemporaryFile object touched the corresponding file before, although it has been closed before.

      The following code is a compressed snipped:

      QString sTempPath = QDir::tempPath();
      QTemporaryFile tempFile(sTempPath + QLatin1String("/XXXXXXXX.txt"));
      tempFile.open();
      QString sTempFileName = tempFile.fileName();
      tempFile.close();

      bool bRenamedStatic = QFile::rename(sTempFileName, sTempPath + "/renamed_STATIC.txt");

      The return value (bRenamedStatic) with Qt 4.5.3 is always false. With Qt 4.4.2 this piece of code worked. It seems that the tempFile object is still holding a handle to file despite it has been closed, inhibiting the rename operation (due to a sharing violation error).

      Attachments

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

        Activity

          People

            biochimia João Abecasis
            jenssch2 Jens Schmeling
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes