Skip to content

Commit

Permalink
qt: add patch to sort local variables by name in qqmljscodegenerator.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
accumulator committed Dec 15, 2023
1 parent aaecf88 commit a6e4f1b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pythonforandroid/recipes/hostqt6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class HostQt6Recipe(Recipe):
version = qt6recipe.version
url = qt6recipe.url

patches = ['qml_codegen_stable_localvars.patch']

build_subdir = 'native-build'

built_libraries = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
--- a/qtdeclarative/src/qmlcompiler/qqmljscodegenerator.cpp 2023-12-15 13:05:45.700077203 +0000
+++ b/qtdeclarative/src/qmlcompiler/qqmljscodegenerator.cpp 2023-12-15 13:33:05.829305331 +0000
@@ -145,16 +145,27 @@

const bool registerIsArgument = isArgument(registerIndex);

- for (auto registerTypeIt = registerTypes.constBegin(), end = registerTypes.constEnd();
- registerTypeIt != end; ++registerTypeIt) {
+ QMap <QString, QQmlJSScope::ConstPtr> rmap;
+
+ for (auto registerTypeIt2 = registerTypes.constBegin(), end = registerTypes.constEnd();
+ registerTypeIt2 != end; ++registerTypeIt2) {

- const QQmlJSScope::ConstPtr storedType = registerTypeIt.key();
+ const QQmlJSScope::ConstPtr storedType2 = registerTypeIt2.key();
+ rmap.insert(registerTypeIt2.value(), storedType2);
+ }
+
+ for (auto registerTypeIt = rmap.constBegin(), end = rmap.constEnd();
+ registerTypeIt != end; ++registerTypeIt) {

- if (generatedVariables.hasSeen(registerTypeIt.value()))
+ const QQmlJSScope::ConstPtr storedType = registerTypeIt.value();
+
+ if (generatedVariables.hasSeen(registerTypeIt.key()))
continue;

result.code += storedType->internalName();
-
+
+ qCDebug(lcAotCompiler) << storedType->internalName() << registerTypeIt.key();
+
const bool isPointer
= (storedType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference);
if (isPointer)
@@ -166,7 +177,7 @@
&& !m_typeResolver->registerIsStoredIn(
function->registerTypes[registerIndex - firstRegisterIndex()],
m_typeResolver->voidType())) {
- result.code += registerTypeIt.value() + u" = "_s;
+ result.code += registerTypeIt.key() + u" = "_s;
result.code += conversion(m_typeResolver->voidType(), storedType, QString());
} else if (registerIsArgument && m_typeResolver->registerIsStoredIn(
argumentType(registerIndex), storedType)) {
@@ -187,7 +198,7 @@
result.code += u'&';
}

- result.code += registerTypeIt.value() + u" = "_s;
+ result.code += registerTypeIt.key() + u" = "_s;

const QString originalValue = u"*static_cast<"_s + castTargetName(original)
+ u"*>(argumentsPtr["_s + QString::number(argumentIndex) + u"])"_s;
@@ -197,7 +208,7 @@
else
result.code += originalValue;
} else {
- result.code += registerTypeIt.value();
+ result.code += registerTypeIt.key();
}
result.code += u";\n"_s;
}

0 comments on commit a6e4f1b

Please sign in to comment.