summaryrefslogtreecommitdiff
path: root/src/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-07-02 15:30:09 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-07-02 20:03:10 +0000
commitf9925dba66a839614fdf1f3e735265f03258f526 (patch)
treec1b8ced52fccb3dbfd1ff72d2c434165da58345b /src/qml
parent73c239c1a402bbfa09f463c28bfbeaf06c7fdaf9 (diff)
downloadqtdeclarative-f9925dba66a839614fdf1f3e735265f03258f526.tar.gz
doc: Explain how to work around the linker removing registrations
Fixes: QTBUG-83402 Change-Id: Ie8dc93afb3c3333d1263dcf0f13b41c833de91d5 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit efbf8f4894b07bc039e4c32f78a00983bcd0945f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
index 496245820a..ec888ae937 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
+++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
@@ -26,6 +26,23 @@ plugins. Library plugins should limit themselves to registering types, as
any manipulation of the engine's root context may cause conflicts or other
issues in the library user's code.
+The linker might erroneously remove the generated type registration
+function as an optimization. You can prevent that by declaring a synthetic
+volatile pointer to the function somewhere in your code. If your module is
+called "my.module", you would add the forward declaration in global scope:
+
+\code
+void qml_register_types_my_module();
+\code
+
+Then add the following snippet of code in the implementation of any function
+that's part of the same binary as the registration:
+
+\code
+volatile auto registration = &qml_register_types_my_module;
+Q_UNUSED(registration);
+\code
+
\section1 TimeExample QML extension plugin
Suppose there is a new \c TimeModel C++ class that should be made available