diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/qtwebviewfunctions.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/webview/qtwebviewfunctions.cpp b/src/webview/qtwebviewfunctions.cpp index b9b2d89..c1c3d6b 100644 --- a/src/webview/qtwebviewfunctions.cpp +++ b/src/webview/qtwebviewfunctions.cpp @@ -38,6 +38,7 @@ #include "qwebviewfactory_p.h" #include "qwebviewplugin_p.h" +#include <QtCore/qcoreapplication.h> QT_BEGIN_NAMESPACE @@ -48,26 +49,42 @@ QT_BEGIN_NAMESPACE \inheaderfile QtWebView */ +// This is a separate function so we can be sure that in non-static cases it can be registered +// as a pre hook for QCoreApplication, ensuring this is called after the plugin paths have +// been set to their defaults. For static builds then this will be called explicitly when +// QtWebView::initialize() is called by the application + +static void initializeImpl() +{ + if (QWebViewFactory::requiresExtraInitializationSteps()) { + // There might be plugins available, but their dependencies might not be met, + // so make sure we have a valid plugin before using it. + // Note: A warning will be printed later if we're unable to load the plugin. + QWebViewPlugin *plugin = QWebViewFactory::getPlugin(); + if (plugin) + plugin->prepare(); + } +} + +#ifndef QT_STATIC +Q_COREAPP_STARTUP_FUNCTION(initializeImpl); +#endif + /*! \fn void QtWebView::initialize() \keyword qtwebview-initialize This function initializes resources or sets options that are required by the different back-ends. - \note The \c initialize() function needs to be called immediately after the QGuiApplication + \note The \c initialize() function needs to be called immediately before the QGuiApplication instance is created. */ void QtWebView::initialize() { - if (QWebViewFactory::requiresExtraInitializationSteps()) { - // There might be plugins available, but their dependencies might not be met, - // so make sure we have a valid plugin before using it. - // Note: A warning will be printed later if we're unable to load the plugin. - QWebViewPlugin *plugin = QWebViewFactory::getPlugin(); - if (plugin) - plugin->prepare(); - } +#ifdef QT_STATIC + initializeImpl(); +#endif } QT_END_NAMESPACE |