diff options
-rw-r--r-- | src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 10 | ||||
-rw-r--r-- | tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp | 10 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index 4f23b8604d..0bfaf6eb1e 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -142,12 +142,12 @@ static QString moc(const QString &name) QFileInfo fi{fileNames.front()}; if (isSupportedSuffix(fi.suffix())) { // Generates a file that contains the header and the implementation: include "filename.moc" - retval += fi.baseName(); + retval += fi.completeBaseName(); retval += ".moc"_L1; } else { // Separate source and header files are generated: include "moc_filename.cpp" retval += "moc_"_L1; - retval += fi.baseName(); + retval += fi.fileName(); retval += ".cpp"_L1; } } else { @@ -161,17 +161,17 @@ static QString moc(const QString &name) QFileInfo source{sourceName}; retval += "moc_"_L1; - retval += source.baseName(); + retval += source.completeBaseName(); retval += ".cpp"_L1; fprintf(stderr, "warning: no header name is provided, assuming it to be \"%s\"\n", - qPrintable(source.baseName() + ".h"_L1)); + qPrintable(source.completeBaseName() + ".h"_L1)); } else { // Both source and header generated: include "moc_headername.cpp" QFileInfo header{headerName}; retval += "moc_"_L1; - retval += header.baseName(); + retval += header.completeBaseName(); retval += ".cpp"_L1; } } diff --git a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp index 0d30d4856e..10bb410bd2 100644 --- a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp +++ b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp @@ -384,6 +384,10 @@ void tst_qdbusxml2cpp::includeMoc_data() QTest::newRow("cpp-only") << ":foo.cpp" << QByteArray("#include \"moc_foo.cpp\"") << QByteArray("warning: no header name is provided, assuming it to be \"foo.h\""); QTest::newRow("header-and-cpp") << "foo_h.h:foo.cpp" << QByteArray("#include \"moc_foo_h.cpp\"") << QByteArray(""); + + QTest::newRow("combined-cpp with dots") << "foo.bar.cpp" << QByteArray("#include \"foo.bar.moc\"") << QByteArray(""); + QTest::newRow("without extension with dots") << "foo.bar" << QByteArray("#include \"moc_foo.bar.cpp\"") << QByteArray(""); + QTest::newRow("header-and-cpp with dots") << "foo.bar_h.h:foo.bar.cpp" << QByteArray("#include \"moc_foo.bar_h.cpp\"") << QByteArray(""); } void tst_qdbusxml2cpp::includeMoc() @@ -402,9 +406,11 @@ void tst_qdbusxml2cpp::includeMoc() QStringList parts = filenames.split(u':'); QFileInfo first{parts.first()}; - if ((parts.size() == 1) && (!first.suffix().isEmpty())) { + const bool firstHasSuffix = QStringList({"h", "cpp", "cc"}).contains(first.suffix()); + + if ((parts.size() == 1) && firstHasSuffix) { checkOneFile(parts.first(), expected); - } else if ((parts.size() == 1) && (first.suffix().isEmpty())) { + } else if ((parts.size() == 1) && (!firstHasSuffix)) { QString headerName{parts.first()}; headerName += ".h"; QString sourceName{parts.first()}; |