From 42aa740df72af0c14f19a498f779d130e8303e54 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 10 Dec 2019 09:00:11 +0100 Subject: [PATCH] rcc: Fix namespace handling for initializer rcc currently always writes the namespace mangling macros in both the initializer constructor and destructor. This patch add the missing handling of the --namespace option for that part of the generated code. [ChangeLog][Tools][rcc] rcc now generates correct code when using the --namespace option. Change-Id: I7e5e608eb0ad267d11d601fc69c1a87d3f655a6e Fixes: QTBUG-80649 Reviewed-by: hjk --- src/tools/rcc/rcc.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 9acbce25ff..7185219d34 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -1478,13 +1478,19 @@ bool RCCResourceLibrary::writeInitializer() writeString(" return 1;\n"); writeString("}\n\n"); - writeByteArray( - "namespace {\n" - " struct initializer {\n" - " initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n" - " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n" - " } dummy;\n" - "}\n"); + + writeString("namespace {\n" + " struct initializer {\n"); + + if (m_useNameSpace) { + writeByteArray(" initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n" + " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n"); + } else { + writeByteArray(" initializer() { " + initResources + "(); }\n" + " ~initializer() { " + cleanResources + "(); }\n"); + } + writeString(" } dummy;\n" + "}\n"); } else if (m_format == Binary) { int i = 4;