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

QUrl's qHash() is inconsistent with its operator==

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.0.2, 5.15.18, 6.2.13, 6.5.8, 6.7.3, 6.8.2, 6.9.0 RC
    • Core: URL Handling
    • None
    • 4
    • Foundation Sprint 127, Foundation Sprint 128

    Description

      There was an assymmetry between comparesEqual() and qHash() that I was finally able to exploit: op== checks !d and d->isEmpty(), while qHash() only checks !d, and then goes over all the QString fields, hashing them.

      This is a reproducer:

          QUrl null;
          QUrl other;
          other.setFragment("meep");
          other.setUrl(QString()); // doesn't overwrite d->fragment
      
          QCOMPARE_EQ(null, other);
          QCOMPARE_EQ(qHash(null), qHash(other)); // fails
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-134896
          # Subject Branch Project Status CR V

          Activity

            People

              mmutz Marc Mutz
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are 2 open Gerrit changes