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

MOC compiler get wrong metamethod tag in some cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.9, 5.12.10, 5.15.2, 6.0.0
    • Build tools: moc
    • None
    • All

    Description

      When using tag with QObject method, if return type is int (or some other types),QMetaMethod::tag() return empty, and QMetaMethod::typeName() return "MY_CUSTOM_TAG int", QMetaMethod::returnType() return invalid.

       

      Object define like this:

      #ifndef Q_MOC_RUN
      #define MY_CUSTOM_TAG
      #endif
      
      #define RET_TYPE int //failed
      //#define RET_TYPE long //failed
      //#define RET_TYPE qint32 //ok
      //#define RET_TYPE double //failed
      //#define RET_TYPE qreal //ok
      
      class TagObj : public QObject
      {
          Q_OBJECT
      public:
          explicit TagObj(QObject *parent = nullptr);
      
          Q_SLOT MY_CUSTOM_TAG RET_TYPE test1(); // failed
          MY_CUSTOM_TAG Q_SLOT RET_TYPE test2(); // ok
      
      public slots:
          MY_CUSTOM_TAG RET_TYPE test3(); // failed
      
      signals:
          MY_CUSTOM_TAG RET_TYPE sig(); // failed
      
      public:
          Q_INVOKABLE MY_CUSTOM_TAG RET_TYPE test4(); // failed
          MY_CUSTOM_TAG Q_INVOKABLE RET_TYPE test5(); // ok
      };
      

      The returns:

      5 "sig()" Type: MY_CUSTOM_TAG int Tag: 
      6 "test1()" Type: MY_CUSTOM_TAG int Tag: 
      7 "test2()" Type: int Tag: MY_CUSTOM_TAG
      8 "test3()" Type: MY_CUSTOM_TAG int Tag: 
      9 "test4()" Type: MY_CUSTOM_TAG int Tag: 
      10 "test5()" Type: int Tag: MY_CUSTOM_TAG
      

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            sfaker jun chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes