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

The 'type mismatch' error is reported when calling a COM object method returning QVariant

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.5.0
    • 5.3.2
    • ActiveX Support
    • None
    • Win 7 64 bit
    • 37f55a5b3be480a8b6ef405bf162dc8015e971b0 (activeqt/5.4, 37f55a5b3be480a8b6ef405bf162dc8015e971b0 , 15.1.2015)

    Description

      My application is ActiveX server that implements custom COM object. If the COM object provides a method (in 'public slots' section) that returns QVariant then calling such a method results in 'type mismatch' error. The problem appeared after switching from Qt 4.8 to Qt 5.3. The COM object is created and used in VBScript.

      The example COM object implementation:

      class TestObject: public QObject
      {
          //Q_OBJECT, Q_CLASSINFO, constructor etc
          ...
      public slots:
          QVariant getValue() const;
      };
      

      The VBScript that reproduces the problem:

      'theTestObject - the COM object representing TestObject object defined above
      theValue = theTestObject.getValue() ' generates type mismatch error

      I think (but did not try) that the problem can be reproduced using this example https://qt-project.org/doc/qt-5-snapshot/activeqt-activeqt-comapp-example.html after changing the line

      QString title() const;
      

      into

      QVariant title() const;
      

      in Document class. This method is 'public', and not 'public slot' but it should not be important.

      Additional investigation shows that the problem is because QVariant type interpretation changed in Qt 5. In Qt 4 it was 'QMetaType::UserType' and in Qt 5 it is 'QMetaType::QVariant' type. Some places in ActiveQt were adapted to this change (by adding extra check for QMetaType::QVariant in the places where only QVariant::UserType was checked in Qt4), but not all of them. The following fix helped me to solve the issue:

      (line 2465 in QtActiveQt/qtactiveqt-opensource-src/src/activeqt/control/qaxserverbase.cpp)
      changed

      if (vt == QVariant::UserType)
      

      into

      if (vt == QVariant::UserType || vt == int(QMetaType::QVariant))
      

      But there are other places where similar change may be required.

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              artem.kostyukovich@duallab.com Artem Kostyukovich
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes