Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.11.1
-
None
-
* Window 10 1803
* MSVC 2017
* Qt 5.11.1
Description
Assuming we have 3 projects. The first is a dynamically linked library that has a Q_COREAPP_STARTUP_FUNCTION that registers a type. The second one is a QML-Plugin that depends on the previous library and itself registers a type. The third is a QtQuick app that loads the plugin, but does not directly depend on the library.
What happens is that when trying to run the application, it fails to load the qml plugin with the error message (text freely translated from german)
QQmlApplicationEngine failed to load component qrc:/main.qml:3 plugin cannot be loaded for module "com.example.plugin": The library E:\build-PluginBug-Desktop_Qt_5_11_1_MSVC2017_64bit-Debug\qml\com\example\plugin\qmlplugin.dll could not be loaded: A DLL initialization routine failed.
Further debugging shows, that the application crashes inside the previously registered Q_COREAPP_STARTUP_FUNCTION inside the qmlRegisterType method! (Stacktrace attached) The curser shows that it crashes when trying to access the static meta object from the QML_GETTYPENAMES macro.
Whats strange about this issue is that this only happens when the main application does not directly depend to the library, i.e. it is loaded only on demand when loading the plugin. Directly linking the app to the lib does not trigger that exception, as the initialization code is loaded before entering the main and not from within the plugin loading. This only happens on windows. Testing on linux shows that loading works completley fine, even indirectly.
A sample project was attached to this issue. You can uncomment Line 5 in app/app.pro and rebuild the project to switch between the indirect loading (only plugin depends on dll) or the direct loading (app and plugin depend on dll).
Attachments
Issue Links
- is required for
-
QTBUG-71036 Qt Core Changes in Qt 6
- Closed
- relates to
-
QTBUG-38876 QObject::metaObject() returns invalid QMetaObject*
- Closed
- replaces
-
QTBUG-73318 [qt widgets] qRegisterWidgetsVariant() order of initialization
- Closed