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

Error String when renaming a file fails is wrong

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.11.0
    • 5.6.2
    • Core: I/O
    • None
    • Windows 7 x64 / Visual Studio 2015
    • d3b6ef6ccf

    Description

      If renaming a file (using QFile::rename) fails, Error String (QIODevice::errorString) may be wrong because reset at the end of the method.

      Faulty Line is the following:

      d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString());

      I suppose condition is reversed, because at this time, current errorString is good.

      Although, I'm still using Qt 5.6.2, it does not seem to be fixed in unreleased Qt 5.11
      https://github.com/qt/qtbase/blob/5.11/src/corelib/io/qfile.cpp#L680

      I should get "Accès refusé." (Access is Denied.) but get "Unknown error" instead which is the default one provided by Qt when errorString is empty (which is the case for closed QFile out).

      To reproduce, just try to rename an already opened file. If desired, I can write an example reproducing this.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            haniboul Manuel Garnier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes