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

adding/removing Q_OBJECT requires explicit invocation of qmake

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 4.8.0
    • Build tools: qmake
    • None
    • Linux x86 Qt 4.8.0

    Description

      Not sure if this is MOC or qmake (also unsure if this is fixed in HEAD, unable to test atm), but here's the steps to reproduce:

      Create two classes. One BaseClass that inherits from QObject, and one InheritedClass that inherits from BaseClass. Put the Q_OBJECT macro in the BaseClass, but do not put it in the Inherited Object (as you should). Add some test signals to each, yada yada.

      In that configuration, the compiler will spit out:
      "undefined reference to `InheritedClass::inheritedSignal`"

      Next, add the Q_OBJECT macro to the InheritedClass (should fix it) and see that it is still broken. This time with error:
      "undefined reference to `vtable for InheritedClass`"

      After doing Build->Clean and Build->Rebuild All (should also fix the problem), you get the same error as directly above:
      "undefined reference to `vtable for...`"

      After manually deleting the build folder, the compilation works as expected.

      Only after a successful build, if you now remove the Q_OBJECT macro from InheritedClass, you get the friendly error:
      "Class declaration lacks Q_OBJECT macro."

      That friendly error should be spat out the first time the Q_OBJECT macro is missing. Adding the Q_OBJECT macro should also fix the problem without needing to delete the build folder (is MOC/qmake not detecting the change and regenerating it's output?). Cleaning should have the same effect as deleting the build folder.

      Attachments

        Issue Links

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

          Activity

            People

              qtbuildsystem Qt Build System Team
              d3fault d3fault
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes