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

Use of QVariant conversions cause asymmetric and intransitive operator==()

    XMLWordPrintable

    Details

    • Commits:
      294e65f8092dd5b624740ee39d52979c7ca6f387

      Description

      The use of QVariant conversions results in asymmetric and intransitive equality comparison, making it unsuitable for use in containers that require EqualityComparable. It also leads to unexpected behaviour in QMap (content depends on insertion order):

      int main()
      {
          QVariant v1(97);
          QVariant v2(QUrl("a"));
          QVariant v3(QChar('a'));
       
          QMap<QVariant, int> s1;
          s1.insert(v1, 1);
          s1.insert(v2, 1);
          s1.insert(v3, 1);
       
          QMap<QVariant, int> s2;
          s2.insert(v3, 1);
          s2.insert(v2, 1);
          s2.insert(v1, 1);
       
          assert(s1.size() == 2);
          assert(s2.size() == 1);
       
          return 0;
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              allan.jensen Allan Sandfeld Jensen
              Reporter:
              hjk hjk
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes