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

QVariant::toList() different behaviour with differrent compilers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.15.11, 6.4
    • Core: Object Model
    • None
    • MSVC2019 and MinGW is running on a Windows 10 machine.
      GCC is on a Linux VM with Ubuntu 20.04.2 LTS

      I encountered the issue with QT versions 5.15.x but could reproduce it on 6.4 too in all mentioned environments.
    • Linux/Wayland, Windows
    • Foundation PM Staging

    Description

      According documentation, QVariant::toList() converts a variant to a list, if its a QVariantList.

      It does so if I use MSVC2019 compiler, but not with MinGW/GCC. When I use MinGW/GCC, it produces a new List and puts the intended List into that.

       

      Example:

      QVariant variant = QVariantList {1, 2, 3};
      QVariantList
      list = variant.toList();
      qInfo() << "variant:" << variant << "is" << QMetaType::typeName(variant.userType());
      qInfo() << "List:" << list << "has" << list.count() << "elements"

       

      Output with MSVC2019  (considered correct):
      variant: QVariant(QVariantList, (QVariant(int, 1), QVariant(int, 2), QVariant(int, 3))) is QVariantList
      List: (QVariant(int, 1), QVariant(int, 2), QVariant(int, 3)) has 3 elements

       

      Output with GCC/MinGW 64 bit (considered wrong):
      variant: QVariant(QVariantList, (QVariant(int, 1), QVariant(int, 2), QVariant(int, 3))) is QVariantList
      List: (QVariant(QVariantList, (QVariant(int, 1), QVariant(int, 2), QVariant(int, 3)))) has 1 elements

       

      With debugging, one can see that in those situations, the intended list with 3 elements is the one and only element in 'root' list. I expected the list of three elements as 'root' list like MSVC2019 produces.

      Attachments

        Activity

          People

            thiago Thiago Macieira
            michelcalonder Michel Calonder
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: