From 76c4767716e3f3225ac433fe41c23891f51bebcf Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Mon, 31 Jan 2022 17:19:23 +0100 Subject: Avoid including self in the generated qmltc code Somehow this works (?) but is meaningless. In the (special) case of QT_QMLTC_FILE_BASENAME it even works by accident due to the test binary having a suitable include: for the NameConflict.qml, which is renamed to ResolvedNameConflict{.h,.cpp} we still have hand-written nameconflict.h Let's ignore this mess for now (it needs to just be deleted eventually) and just provide minimal changes for the stuff to (continue to) work Change-Id: Ic18f17463d0c60d9b02e3d3824d99605a161ae14 Reviewed-by: Ulf Hermann (cherry picked from commit 9a30895128728f9f1720ab7cb53e90e5e823a568) Reviewed-by: Qt Cherry-pick Bot --- tools/qmltc/prototype/qml2cppdefaultpasses.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp index 870f94359a..586cc85754 100644 --- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp +++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp @@ -527,7 +527,7 @@ QHash makeUniqueCppNames(const Qml2CppContext &context, } static void setupQmlCppType(const Qml2CppContext &context, const QQmlJSScope::Ptr &type, - QString filePath) + const QString &filePath) { Q_ASSERT(type); if (filePath.isEmpty()) { @@ -543,8 +543,10 @@ static void setupQmlCppType(const Qml2CppContext &context, const QQmlJSScope::Pt } // TODO: this does not cover QT_QMLTC_FILE_BASENAME renaming - filePath = QFileInfo(filePath).baseName().toLower() + u".h"_qs; - type->setFileName(filePath); // this file name will be discovered during findCppIncludes + if (filePath != context.documentUrl) { + // this file name will be discovered during findCppIncludes + type->setFileName(QFileInfo(filePath).baseName().toLower() + u".h"_qs); + } const auto properties = type->ownProperties(); for (auto it = properties.cbegin(); it != properties.cend(); ++it) { -- cgit v1.2.3