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

Cannot use QHash<int,QByteArray> and Remote Objects in the same project

    XMLWordPrintable

Details

    Description

      If invokable function has QHash<int, QByteArray>, it will cause linker error if header of any other QObject class includes a Remote Objects header because QIntHash in qtremoteobjects/src/remoteobjects/qtremoteobjectglobal.h:52 is not exported.

      typedef QHash<int, QByteArray> QIntHash;
      .....
      QT_DECL_METATYPE_EXTERN(QIntHash, /* not exported */)
      

      This happens because CMake includes all moc'd files in generated mocs_compilation.cpp and that then puts everything in the same translation unit. It will cause:

      /usr/bin/ld: CMakeFiles/quickcmake.dir/quickcmake_autogen/mocs_compilation.cpp.o: 
         in function `int qRegisterNormalizedMetaType<QHash<int, QByteArray> >(QByteArray const&)':
      /home/user/Qt/6.6.1/gcc_64/include/QtRemoteObjects/qtremoteobjectglobal.h:57: 
          undefined reference to `qRegisterNormalizedMetaType_QIntHash(QByteArray const&)'
      collect2: error: ld returned 1 exit status
      

      To reproduce try to build attached example.

      Attachments

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

        Activity

          People

            bstottle Brett Stottlemyer
            poikelin Joni Poikelin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes