summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2013-10-18 13:25:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-18 18:01:54 +0200
commitbefe02aa6efeb351439112b27fc43e9866d6ea3d (patch)
treec40aa51f2fe6a59cdd4d5b72a3dc18d3710e7b60 /src/tools
parent4dab27933db18bda3d2a3272bf1f07f68aa80985 (diff)
Fix crash in qdoc startup
the order of initialization of static variables is undefined, and we therefore cannot (safely) initialize the array with static QStrings declared elsewhere. This was leading to crashes in MinGW gcc 4.8.0. Work around the issue by initializing the array at runtime initialization instead. Task-number: QTBUG-34172 Change-Id: I24f0e6af6685fc280d12c8ef90d40b8ebe994450 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/qdoc/main.cpp48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp
index dd72be7f6e..246e4d2d82 100644
--- a/src/tools/qdoc/main.cpp
+++ b/src/tools/qdoc/main.cpp
@@ -68,27 +68,6 @@
QT_BEGIN_NAMESPACE
-/*
- The default indent for code is 4.
- The default value for false is 0.
- The default supported file extensions are cpp, h, qdoc and qml.
- The default language is c++.
- The default output format is html.
- The default tab size is 8.
- And those are all the default values for configuration variables.
- */
-static const struct {
- const QString key;
- const QString value;
-} defaults[] = {
- { CONFIG_CODEINDENT, QLatin1String("4") },
- { CONFIG_FALSEHOODS, QLatin1String("0") },
- { CONFIG_FILEEXTENSIONS, QLatin1String("*.cpp *.h *.qdoc *.qml") },
- { CONFIG_LANGUAGE, QLatin1String("Cpp") },
- { CONFIG_OUTPUTFORMATS, QLatin1String("HTML") },
- { CONFIG_TABSIZE, QLatin1String("8") },
- { QString(), QString() }
-};
bool creationTimeBefore(const QFileInfo &fi1, const QFileInfo &fi2)
{
@@ -268,11 +247,30 @@ static void processQdocconfFile(const QString &fileName)
initialize the configuration with some default values.
*/
Config config(QCoreApplication::translate("QDoc", "qdoc"));
- int i = 0;
- while (!defaults[i].key.isEmpty()) {
- config.setStringList(defaults[i].key, QStringList() << defaults[i].value);
- ++i;
+
+ /*
+ The default indent for code is 4.
+ The default value for false is 0.
+ The default supported file extensions are cpp, h, qdoc and qml.
+ The default language is c++.
+ The default output format is html.
+ The default tab size is 8.
+ And those are all the default values for configuration variables.
+ */
+ static QHash<QString,QString> defaults;
+ if (defaults.isEmpty()) {
+ defaults.insert(CONFIG_CODEINDENT, QLatin1String("4"));
+ defaults.insert(CONFIG_FALSEHOODS, QLatin1String("0"));
+ defaults.insert(CONFIG_FILEEXTENSIONS, QLatin1String("*.cpp *.h *.qdoc *.qml"));
+ defaults.insert(CONFIG_LANGUAGE, QLatin1String("Cpp"));
+ defaults.insert(CONFIG_OUTPUTFORMATS, QLatin1String("HTML"));
+ defaults.insert(CONFIG_TABSIZE, QLatin1String("8"));
}
+
+ QHash<QString,QString>::iterator iter;
+ for (iter = defaults.begin(); iter != defaults.end(); ++iter)
+ config.setStringList(iter.key(), QStringList() << iter.value());
+
config.setStringList(CONFIG_SYNTAXHIGHLIGHTING, QStringList(highlighting ? "true" : "false"));
config.setStringList(CONFIG_SHOWINTERNAL, QStringList(showInternal ? "true" : "false"));
config.setStringList(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL, QStringList(redirectDocumentationToDevNull ? "true" : "false"));