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

Function normalizer doesn't handle const templates properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.5.3, 4.6.0
    • Core: Object Model
    • None
    • Fedora 11, qt-everywhere-opensource-src-4.6.0, gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)
    • df0e6759e8ebc1053f951d3a5398a41156e91913

    Description

      A slot like this:

      template<class T> class MyTemplate {
      	T t;
      }
      
      class MyObject {
      	Q_OBJECT
      	
      public Q_SLOT:
      	const MyTemplate<int> slot();
      };
      

      Results in this normalized name "const MyTemplate<int>", instead of "MyTemplate<int>", as any other const value type. This leads to a compilation error in the generated moc file, here:

          if (_c == QMetaObject::InvokeMetaMethod) {
              switch (_id) {
              case 0: { const MyTemplate<int> _r = f();
                  if (_a[0]) *reinterpret_cast< const MyTemplate<int>*>(_a[0]) = _r; }  break;        ////****   This assignment fails to compile, because of the object constness
              default: ;
              }
      

      Compiler output:

      moc_ModuleManagerImpl.cxx: In member function 'virtual int ModuleManagerImpl::qt_metacall(QMetaObject::Call, int, void**)':
      moc_ModuleManagerImpl.cxx:68: error: passing 'const MyTemplate<int>' as 'this' argument of 'MyTemplate<int>& MyTemplate<int>::operator=(const MyTemplate<int>&)' discards qualifiers

      Ugly solution, in qmetaobject_p.h:191:

      -        } else if (is_ident_char(*(e-1))) { // treat const value as value
      +       } else if (is_ident_char(*(e-1)) || *(e-1) == '>') { // treat const value as value
      

      Cheers~~

      Attachments

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

        Activity

          People

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            bibeh Rafael Reyes Alvarez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes