diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-03-18 15:10:46 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-03-22 11:26:25 +0100 |
commit | 0af76a1c5fe5d2c5ed70154a579175578cee1555 (patch) | |
tree | a6845f4232d4783eab54a72efd68c3cf9a2c95b6 /tools | |
parent | a5f483b15f67044d685db7f91b0fd63fde5fb616 (diff) |
qml: Enable context sharing by default
The qml utility now uses context sharing by default, as previously done by qmlscene.
It can also be disabled in the same way, by specifying --disable-context-sharing.
This is needed for compatibility with QtWebEngine among other things.
Fixes: QTBUG-85107
Change-Id: I6155d32dfc55b385d33e1c805dae601b9710427e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 4c1a69d6c0..865c762bb1 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -99,6 +99,7 @@ static const QString iconResourcePath(QStringLiteral(":/qt-project.org/QmlRuntim static const QString confResourcePath(QStringLiteral(":/qt-project.org/QmlRuntime/conf/")); static bool verboseMode = false; static bool quietMode = false; +static bool glShareContexts = true; static void loadConf(const QString &override, bool quiet) // Terminates app on failure { @@ -330,6 +331,8 @@ static void getAppFlags(int argc, char **argv) QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); } else if (!strcmp(argv[i], "-software") || !strcmp(argv[i], "--software")) { QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); + } else if (!strcmp(argv[i], "-disable-context-sharing") || !strcmp(argv[i], "--disable-context-sharing")) { + glShareContexts = false; } } #else @@ -365,6 +368,10 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) int main(int argc, char *argv[]) { getAppFlags(argc, argv); + + if (glShareContexts) + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + std::unique_ptr<QCoreApplication> app; switch (applicationType) { #ifdef QT_GUI_LIB @@ -444,6 +451,9 @@ int main(int argc, char *argv[]) QCommandLineOption glCoreProfile(QStringLiteral("core-profile"), QCoreApplication::translate("main", "Force use of OpenGL Core Profile.")); parser.addOption(glCoreProfile); + QCommandLineOption glContextSharing(QStringLiteral("disable-context-sharing"), + QCoreApplication::translate("main", "Disable the use of a shared GL context for QtQuick Windows")); + parser.addOption(glContextSharing); // Just for the help text... we've already handled this argument above #endif // QT_GUI_LIB // Debugging and verbosity options QCommandLineOption quietOption(QStringLiteral("quiet"), |