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

QDir::exists() returns true if QDir was constructed with an empty path

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.8.4
    • Core: I/O
    • None
    • Windows 7

    Description

      If you construct a QDir with a junk string, like this:

      QString s = "junk";
      QDir dir(s);
      bool exists = dir.exists(); // false - correct
      

      The exists() test will return false (correct).

      But if you pass an empty string to the constructor, exists() will always return true;

       
      QString s = "";
      QDir dir(s);
      bool exists = dir.exists(); // true - incorrect!
      

      The workaround is to construct the QDir using the default constructor and use the setPath function to initialize it:

       
      QString s = "";
      QDir dir;
      dir.setPath(s);
      bool exists = dir.exists(); // false - correct
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            danny77uk Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes