1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qtwebviewfunctions.h"
5
6#include "qwebviewfactory_p.h"
7#include "qwebviewplugin_p.h"
8
9#include <QtCore/QCoreApplication>
10
11QT_BEGIN_NAMESPACE
12
13/*!
14 \namespace QtWebView
15 \inmodule QtWebView
16 \brief The QtWebView namespace provides functions that makes it easier to set-up and use the WebView.
17 \inheaderfile QtWebView
18*/
19
20// This is a separate function so we can be sure that in non-static cases it can be registered
21// as a pre hook for QCoreApplication, ensuring this is called after the plugin paths have
22// been set to their defaults. For static builds then this will be called explicitly when
23// QtWebView::initialize() is called by the application
24
25static void initializeImpl()
26{
27 if (QWebViewFactory::requiresExtraInitializationSteps()) {
28 // There might be plugins available, but their dependencies might not be met,
29 // so make sure we have a valid plugin before using it.
30 // Note: A warning will be printed later if we're unable to load the plugin.
31 QWebViewPlugin *plugin = QWebViewFactory::getPlugin();
32 if (plugin)
33 plugin->prepare();
34 }
35}
36
37#ifndef QT_STATIC
38Q_COREAPP_STARTUP_FUNCTION(initializeImpl);
39#endif
40
41/*!
42 \fn void QtWebView::initialize()
43 \keyword qtwebview-initialize
44
45 This function initializes resources or sets options that are required by the different back-ends.
46
47 \note The \c initialize() function needs to be called immediately before the QGuiApplication
48 instance is created.
49 */
50
51void QtWebView::initialize()
52{
53#ifdef QT_STATIC
54 initializeImpl();
55#endif
56}
57
58QT_END_NAMESPACE
59

source code of qtwebview/src/webview/qtwebviewfunctions.cpp