summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-02-21 11:46:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-21 13:49:02 +0100
commit4fad7ae76a0ea834a35737e9b79c3ac3818a8713 (patch)
treef9f6ac8de20637ebd8ae9755d0c390bee5095b26
parentb071aeccc0969d3a59db95fb909caa500b800490 (diff)
moc: Fix loading of plugins in release mode.
Generate the plugin meta data with "debug" set to false/true in two code sections #ifdefed QT_NO_DEBUG. Do not use the value of QT_NO_DEBUG set at moc compile time which does not work in release mode/Windows. Change-Id: I0252795ed063bebb2c3b3784f880e64845b5b7e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--src/tools/moc/generator.cpp66
1 files changed, 40 insertions, 26 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 3362a1abc1..c7c7d96487 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -1057,41 +1057,55 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, "}\n");
}
-void Generator::generatePluginMetaData()
+static void writePluginMetaData(FILE *out, const QJsonObject &data)
{
- if (cdef->pluginData.iid.isEmpty())
- return;
+ const QJsonDocument doc(data);
- QJsonObject data;
- data.insert(QLatin1String("IID"), QLatin1String(cdef->pluginData.iid.constData()));
- data.insert(QLatin1String("className"), QLatin1String(cdef->classname.constData()));
- data.insert(QLatin1String("version"), (int)QT_VERSION);
- data.insert(QLatin1String("debug"),
-#ifdef QT_NO_DEBUG
- false
-#else
- true
-#endif
- );
- data.insert(QLatin1String("MetaData"), cdef->pluginData.metaData.object());
- QJsonDocument doc(data);
-
- fprintf(out, "\nQT_PLUGIN_METADATA_SECTION const uint qt_section_alignment_dummy = 42;\n");
- fprintf(out,
- "\nQT_PLUGIN_METADATA_SECTION\n"
- "static const unsigned char qt_pluginMetaData[] = {\n"
- " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', ' ',\n ");
+ fputs("\nQT_PLUGIN_METADATA_SECTION\n"
+ "static const unsigned char qt_pluginMetaData[] = {\n"
+ " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', ' ',\n ", out);
#if 0
fprintf(out, "\"%s\";\n", doc.toJson().constData());
#else
- QByteArray binary = doc.toBinaryData();
- for (int i = 0; i < binary.size() - 1; ++i) {
+ const QByteArray binary = doc.toBinaryData();
+ const int last = binary.size() - 1;
+ for (int i = 0; i < last; ++i) {
fprintf(out, " 0x%02x,", (uchar)binary.at(i));
if (!((i + 1) % 8))
- fprintf(out, "\n ");
+ fputs("\n ", out);
}
- fprintf(out, " 0x%02x\n};\n", (uchar)binary.at(binary.size() - 1));
+ fprintf(out, " 0x%02x\n};\n", (uchar)binary.at(last));
#endif
+}
+
+void Generator::generatePluginMetaData()
+{
+ if (cdef->pluginData.iid.isEmpty())
+ return;
+
+ // Write plugin meta data #ifdefed QT_NO_DEBUG with debug=false,
+ // true, respectively.
+
+ QJsonObject data;
+ const QString debugKey = QStringLiteral("debug");
+ data.insert(QStringLiteral("IID"), QLatin1String(cdef->pluginData.iid.constData()));
+ data.insert(QStringLiteral("className"), QLatin1String(cdef->classname.constData()));
+ data.insert(QStringLiteral("version"), (int)QT_VERSION);
+ data.insert(debugKey, QJsonValue(false));
+ data.insert(QStringLiteral("MetaData"), cdef->pluginData.metaData.object());
+
+ fputs("\nQT_PLUGIN_METADATA_SECTION const uint qt_section_alignment_dummy = 42;\n\n"
+ "#ifdef QT_NO_DEBUG\n", out);
+ writePluginMetaData(out, data);
+
+ fputs("\n#else // QT_NO_DEBUG\n", out);
+
+ data.remove(debugKey);
+ data.insert(debugKey, QJsonValue(true));
+ writePluginMetaData(out, data);
+
+ fputs("#endif // QT_NO_DEBUG\n\n", out);
+
// 'Use' all namespaces.
int pos = cdef->qualified.indexOf("::");
for ( ; pos != -1 ; pos = cdef->qualified.indexOf("::", pos + 2) )