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

When building DLLs using DEF-files, the usage of the address of staticMetaObject might crash the application

    XMLWordPrintable

Details

    Description

      Exporting a C++ class using DEF files has certain advantages (allows cyclic dependencies between DLLs; faster link time when using ordinals; smaller DLLs), and is in general possible by using the decorated names of all functions.

      Qt 4 requires a variable to be exported, ie. the staticMetaObject variable of each Q_OBJECT class. MSDN documents that variables can be exported via DEF files using the DATA keyword, but have to be imported using __declspec(dllimport). If __declspec(dllimport) is not used, then the address of the variable is not resolved correctly, and this crashes in calls to QMetaObject.

      Using __declspec(dllimport) however duplicates the effort exporting, and makes the DEF files less useful.

      If the staticMetaObject variable would be accessed through a function (like in Qt 3), then this would work without problems.

      Attachments

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

        Activity

          People

            bachewii Jens
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes