qmltyperegistrar: Fix file inclusion and writing to stdout
Apparently if you write #include into a raw string literal, the file is
included right there, as part of the string. We don't want this.
Therefore, write the #include as regular string.
Furthermore, drop some dead code, and make sure we actually write to
stdout if no -o option is given.
Amends commit dbe42f6435
.
Change-Id: Ia4074dd486bdf9430acec4ac2564f9e654b5e3a8
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
cc89f62851
commit
ef8cd39b28
|
@ -149,11 +149,11 @@ void QmlTypeRegistrar::write(QTextStream &output)
|
||||||
** WARNING! All changes made in this file will be lost!
|
** WARNING! All changes made in this file will be lost!
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <QtQml/qqml.h>
|
|
||||||
#include <QtQml/qqmlmoduleregistration.h>
|
|
||||||
)"_s;
|
)"_s;
|
||||||
|
|
||||||
|
output << u"#include <QtQml/qqml.h>\n"_s;
|
||||||
|
output << u"#include <QtQml/qqmlmoduleregistration.h>\n"_s;
|
||||||
|
|
||||||
for (const QString &include : m_includes)
|
for (const QString &include : m_includes)
|
||||||
output << u"\n#include <%1>"_s.arg(include);
|
output << u"\n#include <%1>"_s.arg(include);
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,6 @@
|
||||||
|
|
||||||
using namespace Qt::Literals;
|
using namespace Qt::Literals;
|
||||||
|
|
||||||
struct ScopedPointerFileCloser
|
|
||||||
{
|
|
||||||
static inline void cleanup(FILE *handle)
|
|
||||||
{
|
|
||||||
if (handle)
|
|
||||||
fclose(handle);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Produce reliably the same output for the same input by disabling QHash's random seeding.
|
// Produce reliably the same output for the same input by disabling QHash's random seeding.
|
||||||
|
@ -146,8 +137,6 @@ int main(int argc, char **argv)
|
||||||
parser.isSet(followForeignVersioningOption));
|
parser.isSet(followForeignVersioningOption));
|
||||||
typeRegistrar.setTypes(processor.types(), processor.foreignTypes());
|
typeRegistrar.setTypes(processor.types(), processor.foreignTypes());
|
||||||
|
|
||||||
QScopedPointer<FILE, ScopedPointerFileCloser> outputFile;
|
|
||||||
|
|
||||||
if (parser.isSet(outputOption)) {
|
if (parser.isSet(outputOption)) {
|
||||||
// extract does its own file handling
|
// extract does its own file handling
|
||||||
QString outputName = parser.value(outputOption);
|
QString outputName = parser.value(outputOption);
|
||||||
|
@ -159,7 +148,7 @@ int main(int argc, char **argv)
|
||||||
QTextStream output(&file);
|
QTextStream output(&file);
|
||||||
typeRegistrar.write(output);
|
typeRegistrar.write(output);
|
||||||
} else {
|
} else {
|
||||||
QTextStream output(stdin);
|
QTextStream output(stdout);
|
||||||
typeRegistrar.write(output);
|
typeRegistrar.write(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue