qmltyperegistrar: test for missing Component in qmltypes

qmllint was wrongly complaining about missing types because
qmltyperegistrar was not including all required types in the qmltypes
files.
Add a regression test to make sure that we don't run into the problem
mentioned by Mario Emmenlauer in the linked task at QTBUG-118112.

Task-number: QTBUG-118112
Pick-to: 6.8
Change-Id: Id67e9f9927e94ad5aa900c7bf30e85fc977e3e45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Sami Shalayel 2024-08-07 10:20:54 +02:00 committed by Fabian Kosmale
parent b0fd8ef05e
commit c5da722515
4 changed files with 49 additions and 0 deletions

View File

@ -33,6 +33,7 @@ target_link_libraries(tst_qmltyperegistrarPrivate PRIVATE Qt::Core)
qt_internal_add_test(tst_qmltyperegistrar
SOURCES
hppheader.hpp
typereferencinganother.h
# noextheader special case
tst_qmltyperegistrar.cpp tst_qmltyperegistrar.h
foo.cpp foo.h duplicatedExports.h

View File

@ -1133,5 +1133,15 @@ void tst_qmltyperegistrar::preserveVoidStarPropTypes()
}
})"));
}
void tst_qmltyperegistrar::allReferencedTypesCollected()
{
// reproduce the issue from the comment in QTBUG-118112
QVERIFY(qmltypesData.contains(R"(Component {
file: "typereferencinganother.h"
name: "SampleHeader"
accessSemantics: "reference"
prototype: "QObject"
})"));
}
QTEST_MAIN(tst_qmltyperegistrar)

View File

@ -940,6 +940,7 @@ private slots:
void doNotDuplicateQtNamespace();
void doNotDuplicateQObject();
void slotsBeforeInvokables();
void allReferencedTypesCollected();
void omitQQmlV4FunctionPtrArg();
void preserveVoidStarPropTypes();

View File

@ -0,0 +1,37 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTBUG_118112_H
#define QTBUG_118112_H
#include <QtCore/QObject>
#include <QtQml/qqml.h>
class SampleHeader: public QObject {
Q_OBJECT
};
class SampleUser: public QObject {
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(SampleHeader* header READ header WRITE setHeader NOTIFY headerChanged)
Q_PROPERTY(int invalid READ invalid WRITE setInvalid NOTIFY invalidChanged)
public:
SampleHeader* header() const {return m_header;}
void setHeader(SampleHeader* header) {m_header = header;}
int invalid() const { return m_invalid;}
void setInvalid(int invalid) { m_invalid = invalid; }
signals:
void headerChanged();
void invalidChanged();
private:
SampleHeader* m_header;
int m_invalid;
};
#endif // QTBUG_118112_H