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

The QDir path exists when the construct is empty

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.15.0 RC2
    • Core: I/O
    • None
    • All

    Description

      When I use the following code, the output results of these are different. Only QDir outputs the information of exist. When I look at the source code, I find that it is set to the current path when its constructor is empty. The problem arises from the fact that I am still judged to exist when I use the function call passed in QDir to return null value. I think it is unreasonable for such interface design, although the current path will be used when the QDIR structure is empty is written in the official document.

      QString getConfig() {
          return "";
      }
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
      
          if (QDir(getConfig()).exists()) {
              qDebug() << "QDir exist";
          }
          if (QFile((getConfig())).exists()) {
              qDebug() << "QFile exist";
          }
          if (QFileInfo(getConfig()).exists()) {
              qDebug() << "QFileInfo exist";
          }
      
          return app.exec();
      }
      

       

      Attachments

        1. bug.png
          68 kB
          wangpenga wangpenga
        2. setpath_directly.png
          162 kB
          wangpenga wangpenga
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            wangpenga wangpenga wangpenga
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes