diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-12 15:02:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-12 15:02:40 (GMT) |
commit | 7263810f4802a3a6755193f6f2692436600a5e53 (patch) | |
tree | 954812c36d798e684e647dfcc86f286e5bc69d76 /tools | |
parent | 30ea8c49a50e7088c58c6c569450ec8673001962 (diff) | |
parent | 6cd31f7e83292edb6ab2008c1fe3e9dea08dec78 (diff) | |
download | Qt-7263810f4802a3a6755193f6f2692436600a5e53.zip Qt-7263810f4802a3a6755193f6f2692436600a5e53.tar.gz Qt-7263810f4802a3a6755193f6f2692436600a5e53.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/berlin-staging-1:
Help system: Handle all Clucene exceptions.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp | 230 |
1 files changed, 112 insertions, 118 deletions
diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index b65ba2a..6e49e54 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -614,67 +614,69 @@ void QHelpSearchIndexWriter::optimizeIndex() void QHelpSearchIndexWriter::run() { - QMutexLocker mutexLocker(&mutex); +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + QMutexLocker mutexLocker(&mutex); - if (m_cancel) - return; + if (m_cancel) + return; - const bool reindex = this->m_reindex; - const QString collectionFile(this->m_collectionFile); + const bool reindex = this->m_reindex; + const QString collectionFile(this->m_collectionFile); - mutexLocker.unlock(); + mutexLocker.unlock(); - QHelpEngineCore engine(collectionFile, 0); - if (!engine.setupData()) - return; + QHelpEngineCore engine(collectionFile, 0); + if (!engine.setupData()) + return; - const QLatin1String key("CluceneIndexedNamespaces"); - if (reindex) - engine.setCustomValue(key, QLatin1String("")); - - QMap<QString, QDateTime> indexMap; - const QLatin1String oldKey("CluceneSearchNamespaces"); - if (!engine.customValue(oldKey, QString()).isNull()) { - // old style qhc file < 4.4.2, need to convert... - const QStringList indexedNamespaces = engine.customValue(oldKey). - toString().split(QLatin1String("|"), QString::SkipEmptyParts); - foreach (const QString &nameSpace, indexedNamespaces) - indexMap.insert(nameSpace, QDateTime()); - engine.removeCustomValue(oldKey); - } else { - QDataStream dataStream(engine.customValue(key).toByteArray()); - dataStream >> indexMap; - } + const QLatin1String key("CluceneIndexedNamespaces"); + if (reindex) + engine.setCustomValue(key, QLatin1String("")); + + QMap<QString, QDateTime> indexMap; + const QLatin1String oldKey("CluceneSearchNamespaces"); + if (!engine.customValue(oldKey, QString()).isNull()) { + // old style qhc file < 4.4.2, need to convert... + const QStringList indexedNamespaces + = engine.customValue(oldKey).toString() + .split(QLatin1String("|"), QString::SkipEmptyParts); + foreach (const QString &nameSpace, indexedNamespaces) + indexMap.insert(nameSpace, QDateTime()); + engine.removeCustomValue(oldKey); + } else { + QDataStream dataStream(engine.customValue(key).toByteArray()); + dataStream >> indexMap; + } - QString indexPath = m_indexFilesFolder; + QString indexPath = m_indexFilesFolder; - QFileInfo fInfo(indexPath); - if (fInfo.exists() && !fInfo.isWritable()) { - qWarning("Full Text Search, could not create index (missing permissions for '%s').", qPrintable(indexPath)); - return; - } + QFileInfo fInfo(indexPath); + if (fInfo.exists() && !fInfo.isWritable()) { + qWarning("Full Text Search, could not create index (missing permissions for '%s').", + qPrintable(indexPath)); + return; + } - emit indexingStarted(); + emit indexingStarted(); - QCLuceneIndexWriter *writer = 0; - QCLuceneStandardAnalyzer analyzer; - const QStringList registeredDocs = engine.registeredDocumentations(); + QCLuceneIndexWriter *writer = 0; + QCLuceneStandardAnalyzer analyzer; + const QStringList registeredDocs = engine.registeredDocumentations(); - QLocalSocket localSocket; - localSocket.connectToServer(QString(QLatin1String("QtAssistant%1")) - .arg(QLatin1String(QT_VERSION_STR))); + QLocalSocket localSocket; + localSocket.connectToServer(QString(QLatin1String("QtAssistant%1")) + .arg(QLatin1String(QT_VERSION_STR))); - QLocalServer localServer; - bool otherInstancesRunning = true; - if (!localSocket.waitForConnected()) { - otherInstancesRunning = false; - localServer.listen(QString(QLatin1String("QtAssistant%1")) - .arg(QLatin1String(QT_VERSION_STR))); - } + QLocalServer localServer; + bool otherInstancesRunning = true; + if (!localSocket.waitForConnected()) { + otherInstancesRunning = false; + localServer.listen(QString(QLatin1String("QtAssistant%1")) + .arg(QLatin1String(QT_VERSION_STR))); + } -#if !defined(QT_NO_EXCEPTIONS) - try { -#endif // check if it's locked, and if the other instance is running if (!otherInstancesRunning && QCLuceneIndexReader::isLocked(indexPath)) QCLuceneIndexReader::unlock(indexPath); @@ -706,7 +708,8 @@ void QHelpSearchIndexWriter::run() removeDocuments(indexPath, namespaceName); } else { QString path = engine.documentationFileName(namespaceName); - if (indexMap.value(namespaceName) < QFileInfo(path).lastModified()) { + if (indexMap.value(namespaceName) + < QFileInfo(path).lastModified()) { // make sure we remove some outdated indexed stuff indexMap.remove(namespaceName); removeDocuments(indexPath, namespaceName); @@ -727,94 +730,85 @@ void QHelpSearchIndexWriter::run() indexMap.clear(); writer = new QCLuceneIndexWriter(indexPath, analyzer, true); } -#if !defined(QT_NO_EXCEPTIONS) - } catch (...) { - qWarning("Full Text Search, could not create index writer in '%s'.", - qPrintable(indexPath)); - return; - } -#endif -#if !defined(QT_NO_EXCEPTIONS) - try { -#endif writer->setMergeFactor(100); writer->setMinMergeDocs(1000); writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); -#if !defined(QT_NO_EXCEPTIONS) - } catch (...) { - qWarning("Full Text Search, could not set writer properties."); - return; - } -#endif - QStringList namespaces; - foreach(const QString &namespaceName, registeredDocs) { - mutexLocker.relock(); - if (m_cancel) { - closeIndexWriter(writer); - emit indexingFinished(); - return; - } - mutexLocker.unlock(); + QStringList namespaces; + foreach(const QString &namespaceName, registeredDocs) { + mutexLocker.relock(); + if (m_cancel) { + closeIndexWriter(writer); + emit indexingFinished(); + return; + } + mutexLocker.unlock(); - namespaces.append(namespaceName); - if (indexMap.contains(namespaceName)) - continue; + namespaces.append(namespaceName); + if (indexMap.contains(namespaceName)) + continue; - const QList<QStringList> attributeSets = - engine.filterAttributeSets(namespaceName); + const QList<QStringList> attributeSets = + engine.filterAttributeSets(namespaceName); - if (attributeSets.isEmpty()) { - const QList<QUrl> docFiles = indexableFiles(&engine, namespaceName, - QStringList()); - if (!addDocuments(docFiles, engine, QStringList(), namespaceName, - writer, analyzer)) - break; - } else { - bool bail = false; - foreach (const QStringList &attributes, attributeSets) { - const QList<QUrl> docFiles = indexableFiles(&engine, - namespaceName, attributes); - if (!addDocuments(docFiles, engine, attributes, namespaceName, - writer, analyzer)) { - bail = true; + if (attributeSets.isEmpty()) { + const QList<QUrl> docFiles = indexableFiles(&engine, namespaceName, + QStringList()); + if (!addDocuments(docFiles, engine, QStringList(), namespaceName, + writer, analyzer)) break; + } else { + bool bail = false; + foreach (const QStringList &attributes, attributeSets) { + const QList<QUrl> docFiles = indexableFiles(&engine, + namespaceName, attributes); + if (!addDocuments(docFiles, engine, attributes, namespaceName, + writer, analyzer)) { + bail = true; + break; + } } + if (bail) + break; } - if (bail) - break; - } - mutexLocker.relock(); - if (!m_cancel) { - QString path(engine.documentationFileName(namespaceName)); - indexMap.insert(namespaceName, QFileInfo(path).lastModified()); - writeIndexMap(engine, indexMap); + mutexLocker.relock(); + if (!m_cancel) { + QString path(engine.documentationFileName(namespaceName)); + indexMap.insert(namespaceName, QFileInfo(path).lastModified()); + writeIndexMap(engine, indexMap); + } + mutexLocker.unlock(); } - mutexLocker.unlock(); - } - closeIndexWriter(writer); + closeIndexWriter(writer); - mutexLocker.relock(); - if (!m_cancel) { - mutexLocker.unlock(); - - QStringList indexedNamespaces = indexMap.keys(); - foreach(const QString &namespaceName, indexedNamespaces) { - mutexLocker.relock(); - if (m_cancel) - break; + mutexLocker.relock(); + if (!m_cancel) { mutexLocker.unlock(); - if (!namespaces.contains(namespaceName)) { - indexMap.remove(namespaceName); - writeIndexMap(engine, indexMap); - removeDocuments(indexPath, namespaceName); + QStringList indexedNamespaces = indexMap.keys(); + foreach(const QString &namespaceName, indexedNamespaces) { + mutexLocker.relock(); + if (m_cancel) + break; + mutexLocker.unlock(); + + if (!namespaces.contains(namespaceName)) { + indexMap.remove(namespaceName); + writeIndexMap(engine, indexMap); + removeDocuments(indexPath, namespaceName); + } } } + +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("%s: Failed because of CLucene exception.", Q_FUNC_INFO); } +#endif + emit indexingFinished(); } |