diff --git a/templates/lib/node.cpp b/templates/lib/node.cpp index 2f85cfce..a933eab6 100644 --- a/templates/lib/node.cpp +++ b/templates/lib/node.cpp @@ -188,7 +188,14 @@ QList< FilterExpression > AbstractNodeFactory::getFilterExpressionList( const QS QStringList AbstractNodeFactory::smartSplit( const QString &str ) const { - const QRegExp r( QStringLiteral( "(" // match +#if defined(Q_CC_MSVC) +// MSVC doesn't like static string concatenations like L"foo" "bar", as +// results from QStringLiteral, so use QLatinString here instead. +#define STRING_LITERAL QLatinString +#else +#define STRING_LITERAL QStringLiteral +#endif + const QRegExp r( STRING_LITERAL( "(" // match "(?:[^\\s\\\'\\\"]*" // things that are not whitespace or escaped quote chars "(?:" // followed by "(?:\"" // Either a quote starting with " @@ -203,6 +210,8 @@ QStringList AbstractNodeFactory::smartSplit( const QString &str ) const ")" // End match ) ); +#undef STRING_LITERAL + QStringList l; int count = 0; int pos = 0; diff --git a/templates/tests/testgenerictypes.cpp b/templates/tests/testgenerictypes.cpp index 347743d3..0bf558b6 100644 --- a/templates/tests/testgenerictypes.cpp +++ b/templates/tests/testgenerictypes.cpp @@ -647,8 +647,15 @@ void TestGenericTypes::testNestedContainers() Grantlee::Context c; c.insert( QStringLiteral( "stack" ), QVariant::fromValue( getMapStack() ) ); +#if defined(Q_CC_MSVC) +// MSVC doesn't like static string concatenations like L"foo" "bar", as +// results from QStringLiteral, so use QLatinString here instead. +#define STRING_LITERAL QLatinString +#else +#define STRING_LITERAL QStringLiteral +#endif Grantlee::Template t1 = engine.newTemplate( - QStringLiteral( "{% for map in stack %}" + STRING_LITERAL( "{% for map in stack %}" "(M {% for key, list in map.items %}" "({{ key }} : (L {% for vector in list %}" "(V {% for number in vector %}" @@ -659,6 +666,8 @@ void TestGenericTypes::testNestedContainers() "{% endfor %}" ) , QStringLiteral( "template1" ) ); +#undef STRING_LITERAL + QString result = t1->render( &c ); QString expectedResult = QStringLiteral(