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

QString::compare yields different results for null or empty string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.10.1
    • 5.10.0
    • None
    • Qt 5.10.0, Win32
    • ea6675374fa6e94bd4cf10613c85cee2c724bcdc

    Description

      We discovered that QString::compare handles null and empty strings differently:

          QString nullString;
          QString otherData("Some text");
          int nResult1 = nullString.compare(otherData, Qt::CaseInsensitive);
          QString emptyString("");
          int nResult2 = emptyString.compare(otherData, Qt::CaseInsensitive);
      

      With Qt 5.10 nResult1 equals 9 and nResult2 equals -1. In previous versions, e.g. 5.7, both results were equal -1;

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            phbaer Philipp Baer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes