The argument "-a" passed after "--" was being interpreted as the -a
option of the qml tool itself instead of being passed along to the qml
program as a positional argument.
Fixes: QTBUG-136120
Pick-to: 6.9 6.8 6.5
Change-Id: I602aea84e4766abeb47adce0f739f12315a70b24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We are sporadically seeing weird failures on macOs that the types from
the module are not available. This could not be reproduced reliably, but
we suspect that the linker might discard the (static ctor invoking the)
registration function.
Avoid this by calling it explictily.
Change-Id: Ic405dd5f226af3580efe7dd5d8202a6a263a367e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
It works since 6.6 regardless, but the help text had no mentioning of it
at all.
Also use the nicer "opengl" instead of "gl" (both are accepted by
QSG_RHI_BACKEND anyway)
Pick-to: 6.7 6.6
Change-Id: Ibf6de9411d8641d244b8750fd7a015781a9297b1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This handles the --version, --help and --help-all options.
Apparently there's no other way to handle --help-all, because
addHelpOption() adds two options but only returns one of them.
Amends bb6602bca2
Fixes: QTBUG-100678
Pick-to: 6.2 6.5 5.15
Change-Id: Iddd1ba2dae975d7256935d8d357e2f3ac6c013d6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Use qt_add_qml_module correctly, apply a standard resource path, and
move the files into the same directory as the module. Use upper case
file names for the (re-usable) container definitions and lower case file
names for the configuration entry points. This way we only need one
directory and therefore only one QML module.
Change-Id: Ic45dd0e8866f8f62bbaa639b6f138e9a75e05863
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Otherwise we leak a lot of memory if any of the exit() calls is
triggered.
Change-Id: I338abe2ef63217e6b80ffc2f8fe65d9cac03d994
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The QTranslator was destructed right after it was loaded because it was
inside a scope
Pick-to: 6.5
Change-Id: I8c9d1604652f18f7d15aa7a0045f580cd8a25063
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Restore the --transparent and --multisample options. Also make the
default QSurfaceFormat setting universal (no need to tie it to the
option of forcing a core profile context), and prevent the warning
that is printed when the default surfaceformat is changed after the
application is already created with AA_ShareOpenGLContexts set. This
involves having to handle the relevant arguments manually early on,
not through QCommandLineParser.
All this matches the qmlscene behavior.
NB qmlscene requests 16 samples with --multisample which is completely
pointless in practice. Use the common 4 now.
Change-Id: I671e5f22846a715675ea936bb7cf2a31a849dc28
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
When shaders are generated dynamically, such as with QtQuick3D, cached
shaders may get out of date if the QML file is changed.
Change-Id: I2c5484765e30da5c13fd175a9fcbad2473d55e62
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
We're not actually interested in whether an object is a window, and we
don't really care how many objects are created. The only thing we need
to know is whether at least one object is alive after all files have
been processed.
Pick-to: 6.5
Fixes: QTBUG-110112
Change-Id: I8d79359f3fb7ec5a54545dc5858cf310b0f52935
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
Task-number: QTBUG-99313
Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.
Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
If you do QUrl::fromLocalFile() on a file name starting with ":" you get
a rather curious URL.
Change-Id: I07d35e792b87a66fffc9c992462d92a4c0c8040d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
[ChangeLog][QtQml][qml] The QML Runtime tool's --dummy-data option
is now deprecated, because context properties are deprecated. This
option will be removed in a future version of Qt.
Task-number: QTBUG-96800
Change-Id: Id6ef8a384f6239ddeebd6c4f84854bbeaf630279
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Also, --list-conf will now list the conf files that it finds;
and --verbose will show more information about the path(s) to them.
[ChangeLog][QtQml][qml] The QML Runtime tool's -c / --config option
now can find a directory containing a file called configuration.qml
under QStandardPaths::AppConfigLocation, in addition to being able to
give the full path to the configuration file, as before. I.e. on
Linux you could write a custom configuration into
~/.config/QtProject/Qml Runtime/myconfig/configuration.qml
and then use it via qml -c myconfig somefile.qml. The --list-conf
option will list the configurations that can be found in this way.
Task-number: QTBUG-26366
Fixes: QTBUG-96740
Change-Id: I72798b22255b71b9d4184a67f86b249766b64233
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Instead of std::exit() use the early return mechanism we already have so
that any existing objects are gracefully destroyed.
Change-Id: Icb197879cc33ab22f07fc1486da44f9ff5b177bc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Rather, parent them to the watcher. The watcher lives in the main()
function's scope.
Change-Id: I2ac1d14d80d4100756a3ad94b6502d46fda30074
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
Already possible to do the same using environment variables but this ensures greater compatibility with qmlscene
and better ease of use.
Change-Id: I214aec41aad4369f54bca887e91ccb879153c8be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
The "qml" tool was the only way of loading QML files that would respect
a shebang line. This is problematic as this way you cannot load such
files programatically using QQmlComponent, limiting their re-use. Common
tools like Qt Creator, but also qmllint, qmlformat, qmlcachegen, etc
would not recognize files with shebangs.
By moving she-bang support directly in the lexer all tools implicitly
support it.
Note that we could just as easily support '#' as extra comment
character along with //, but here we narrowly add support for in
the first line only, as node does (this means that javascript files
using she-bang accepted by node, are now accepted also by qml).
The only tool needing some adjustments is qmlformat, that has to emit
the she-bang again as she-bang and as first line.
Add tests for qmlformat, and sprinkle some she-bangs in the other
tests just to be sure it doesn't affect anything.
Change-Id: I1f6d881c7438bdb23163b5dbe829d59a35d11132
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This is required to remove the ; from the macro with Qt 6.
Task-number: QTBUG-82978
Change-Id: Iead53d18fd790fb2d870d80ef2db79666f0d2392
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Accelerated graphics is now possible without OpenGL support. With
this change, a Qt build with -no-opengl can still run Qt Quick with
a Vulkan, Metal, or Direct3D backend.
Fixes: QTBUG-84027
Change-Id: Ib63c733d28cfdf7de16b138df136fa7628e1747b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
No reason to have this in the API in 6.0, and it's already not emitted
at all in dev (because the direct OpenGL code path is now gone from the
render loops)
Some simple GL string printing has been removed from qml/qmlscene. This
opt-in feature has not been useful in practice anyway since QSG_INFO=1
prints the same things.
[ChangeLog][Qt Quick][QQuickWindow] The openGLContextCreated signal has
been removed from QQuickWindow.
Change-Id: Ifb647bbd1e828ebad2b775e8ce5c38723a0cda13
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
The global static map of file selectors is not thread safe. If you add a
file selector to engine A running in thread 1, you cannot at the same
time retrieve the file selector of engine B running in thread 2. Alas,
we only need the static map to discern file selectors from other URL
interceptors, and we only need to do this on QQmlFileSelector::get(),
which we don't use. Unfortunately it is public API, though.
Deprecate QQmlFileSelector::get() and add a different hack to discern
the interceptors for the case that it's still called. Also remove the
duplicate setExtraSelectors() method.
For this to work, we also add a method to QQmlApplicationEngine that
allows us to pass extra file selectors and delay the initialization of
QQmlApplicationEngine's QQmlFileSelector until the first file is loaded.
[ChangeLog][QML] QQmlFileSelector::get() is deprecated. You can use the
new method QQmlAplicationEngine::setExtraFileSelectors() to pass extra
selectors to QQmlApplicationEngine's internal QQmlFileSelector.
Manually created QQmlFileSelectors should be configured immediately
after creation, before they are used by the QQmlEngine.
Change-Id: Ia61a93777dc910b441a03ffb42d35a2a224c0e26
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
qml and qmltime were still using qmlRegisterType() for some internals.
Let's get rid of those.
Change-Id: I68c0e7213f3b5b28670364c4db1cdec41d299b7d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
If QML_CORE_PROFILE is defined we use the CoreProfile surface format.
This is required for QtQuick3D.
For consistency we also introduce QSG_CORE_PROFILE.
Adding QSG_CORE_PROFILE also to qmlscene.
Change-Id: I4feee91740162cf36fa2668695b74f5a1279bb89
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This allows defining file selectors using a command-line option.
[ChangeLog][QtQml][qml] The QML Runtime tool --selector option now allows
defining a custom QQmlFileSelector.
Change-Id: I1be5efd273b2f387df72b1d5057f7281e5c0c156
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Move the Open GL and scaling options setting QCoreApplication
attributes into the helper getAppFlags() which already
handles the application type.
Change getAppFlags() to not modify argv which is not necessary
since the parser will accept the options.
Change-Id: Ib2f94f832e6551a938ff0e9bfe27649850d38d1e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Using this technique we can automatically register all necessary
revisions and minor versions of a type, using the metaobject system.
This greatly reduces the potential for mistakes and resulting
incompatibilities between versions of imports.
We assume that for each type we need to register all revisions of its
super types and its attached type, and that the revisions match. That
is, if you import version X of type A, you will also get version X of
its attached type and of any super types. As we previously didn't take
these dependencies into account when manually registering the types, a
number of extra revisions are now registered for some types.
Potentially, we can now generate the qmltypes files at compile time,
using moc.
Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The qmlscene --resize-to-root feature has always been missing from
the qml runtime tool; however it was already possible to add it by
writing a custom configuration file. Now we support loading different
configurations from resources as well as from the filesystem, and
the first new configuration being added here is resizeToItem.qml
which provides behavior equivalent to qmlscene --resize-to-root.
When the argument given to --config ends with .qml, by convention
it's to be loaded from the filesystem; whereas configurations from
resources are specified without the .qml extension (to make the
command line shorter).
[ChangeLog][QtQml][qml] The QML Runtime tool now has default behavior
matching qmlscene when the root QML object is an Item: it will be
wrapped in a Window which will resize the Item when the Window is
resized. But you can alternatively use the --config resizeToItem
option, resulting in the same behavior as qmlscene --resizeToRoot:
resizing the root Item programmatically causes the wrapping Window to
be resized. Behavior can still be customized in other ways using the
--config option with an external QML configuration file.
Task-number: QTBUG-53557
Change-Id: Icdcbbd12258105c33b64634049d735e022dfbd06
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
[ChangeLog][QtQml][qml] The QML Runtime tool --quiet option now
disables categorized logging in addition to qDebug, qInfo, qWarning
and qFatal, except for some early QPA-level categorized logging that
occurs during application construction. You can still override
specific categories by setting QT_LOGGING_CONF or QT_LOGGING_RULES.
Change-Id: Icf986a7fa9980d07beed308df8f69fcc4da9d771
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Some advantages:
- support double-hyphen options as well as the existing single-hyphen options
- support translation of the usage text
[ChangeLog][QtQml][qml] The QML Runtime tool now accepts command-line
arguments in double-dash GNU style as well as the old single-dash style.
Task-number: QTBUG-53557
Change-Id: I9929c63841272894640abe254efaea9773eee633
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
A new one has been drawn; use it on all platforms, not just on macOS.
It is now also used as the default window icon, to be more identifiable
when minimized, etc. Of course it can be overridden by plugins that
can be loaded from qml.
[ChangeLog][QtQml][qml] The QML Runtime tool now has an updated
application icon and a default window icon. QtQuick applications
can still use QWindow::setIcon() to override the window icon.
Task-number: QTBUG-70826
Task-number: QTBUG-74662
Change-Id: I8671d0c99f7f4283dbe2dc4c605abb560f7bf1a1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>