diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-16 12:58:48 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-02 19:48:43 +0100 |
commit | 344f09bb98eba8e9add3cab2d72cc0fe029ec4d3 (patch) | |
tree | 05d0d395e437184b264147bf80612b4f36fe33f1 /src/qml/qml/qqmlglobal_p.h | |
parent | 3c2c53f0ba8995a50bbf44220f95f9cd93f58821 (diff) |
QtQml: Allow more fine grained control of the disk cache
You can now enable and disable the AOT-compiled code and the loading and
saving of .qmlc files separately.
Fixes: QTBUG-101358
Change-Id: I1305c4f2f75d8cff544a127e956589d1ed1aeb52
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlglobal_p.h')
-rw-r--r-- | src/qml/qml/qqmlglobal_p.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index f7a50e8350..918f95993f 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -24,20 +24,24 @@ QT_BEGIN_NAMESPACE +inline bool qmlConvertBoolConfigOption(const char *v) +{ + return v != nullptr && qstrcmp(v, "0") != 0 && qstrcmp(v, "false") != 0; +} + +template<typename T, T(*Convert)(const char *)> +T qmlGetConfigOption(const char *var) +{ + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var))) + return Convert(qgetenv(var)); + return Convert(nullptr); +} #define DEFINE_BOOL_CONFIG_OPTION(name, var) \ static bool name() \ { \ - static enum { Yes, No, Unknown } status = Unknown; \ - if (status == Unknown) { \ - status = No; \ - if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(#var))) { \ - const QByteArray v = qgetenv(#var); \ - if (v != "0" && v != "false") \ - status = Yes; \ - } \ - } \ - return status == Yes; \ + static const bool result = qmlGetConfigOption<bool, qmlConvertBoolConfigOption>(#var); \ + return result; \ } /*! |