From befe02aa6efeb351439112b27fc43e9866d6ea3d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 18 Oct 2013 13:25:19 +0200 Subject: Fix crash in qdoc startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jędrzej Nowacki --- src/tools/qdoc/main.cpp | 48 +++++++++++++++++++++++------------------------- 1 file 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 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::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")); -- cgit v1.2.3