diff options
author | Dominik Holland <dominik.holland@qt.io> | 2019-11-28 15:46:39 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2019-11-28 15:46:39 +0100 |
commit | 945017497c8dd87c0a81abd15de46ba65eee62ed (patch) | |
tree | 4aef8224c6fcebc3c4e7b50a9b5b2bce27cd16cc | |
parent | 86aa73a79cb57daf045a3ad345d6a321ac404bf1 (diff) |
ivigenerator: Use QStringLiterals for string default_values
For default_values in our simulation backends, QLatin1String() were
generated so far, but when using these for initializing a struct
with only one string property, this caused problems, as the structs
are using QStrings and because of an additional QVariant constructor
this caused some ambiguity for the compiler.
Switching to QStringLiterals fixes this problem, as the QString
constructor is used in this case.
Change-Id: Iae34ef290ec5683665fdfdb75b633e748ee371f3
Fixes: AUTOSUITE-1340
-rwxr-xr-x | src/tools/ivigenerator/generate.py | 6 | ||||
-rw-r--r-- | tests/auto/core/ivigenerator/org.example.echo.qface | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py index c19de65..ee0e415 100755 --- a/src/tools/ivigenerator/generate.py +++ b/src/tools/ivigenerator/generate.py @@ -193,7 +193,7 @@ def test_type_value(symbol): if t.is_bool: return 'true' if t.is_string: - return '"TEST STRING"' + return 'QStringLiteral("TEST STRING")' if t.is_real: return '1234.5678' if t.is_var: @@ -248,10 +248,10 @@ def default_value_helper(symbol, res): else: return 'false' if t.is_string: - return 'QLatin1String("{0}")'.format(res.replace("\\", "\\\\")) + return 'QStringLiteral("{0}")'.format(res.replace("\\", "\\\\")) if t.is_var: if isinstance(res, str): - res = 'QLatin1String("{0}")'.format(res) + res = 'QStringLiteral("{0}")'.format(res) return 'QVariant({0})'.format(res) return '{0}'.format(res) diff --git a/tests/auto/core/ivigenerator/org.example.echo.qface b/tests/auto/core/ivigenerator/org.example.echo.qface index 17a519c..faed373 100644 --- a/tests/auto/core/ivigenerator/org.example.echo.qface +++ b/tests/auto/core/ivigenerator/org.example.echo.qface @@ -34,6 +34,9 @@ interface Echo { WeekDay weekDay; TestEnum testEnum; real UPPERCASEPROPERTY; + /* AUTOSUITE-1340 */ + @config_simulator: { default: ["Hello Qt"] } + OnlyAStringInAStruct stringInAStructProperty; string echo(string msg); string id() const; @@ -144,3 +147,8 @@ struct Combo { struct AnotherStruct { int justANumber; } + +/* AUTOSUITE-1340 */ +struct OnlyAStringInAStruct { + string myString; +} |