Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the Qt Assistant of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    431431    {
    432432        QTextStream textStream(data);
    433         QByteArray charSet = QHelpGlobal::charsetFromData(data).toLatin1();
    434         textStream.setCodec(QTextCodec::codecForName(charSet.constData()));
     433        const QByteArray &codec = QHelpGlobal::codecFromData(data).toLatin1();
     434        textStream.setCodec(QTextCodec::codecForName(codec.constData()));
    435435
    436436        QString stream = textStream.readAll();
     
    579579    const QString &indexFilesFolder, bool reindex)
    580580{
     581    wait();
    581582    mutex.lock();
    582583    this->m_cancel = false;
     
    591592void QHelpSearchIndexWriter::optimizeIndex()
    592593{
    593     if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) {
    594         if (QCLuceneIndexReader::isLocked(m_indexFilesFolder))
    595             return;
    596 
    597         QCLuceneStandardAnalyzer analyzer;
    598         QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false);
    599         writer.optimize();
    600         writer.close();
    601     }
     594#if !defined(QT_NO_EXCEPTIONS)
     595    try {
     596#endif
     597        if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) {
     598            if (QCLuceneIndexReader::isLocked(m_indexFilesFolder))
     599                return;
     600
     601            QCLuceneStandardAnalyzer analyzer;
     602            QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false);
     603            writer.optimize();
     604            writer.close();
     605        }
     606#if !defined(QT_NO_EXCEPTIONS)
     607    } catch (...) {
     608        qWarning("Full Text Search, could not optimize index.");
     609        return;
     610    }
     611#endif
    602612}
    603613
     
    640650    QFileInfo fInfo(indexPath);
    641651    if (fInfo.exists() && !fInfo.isWritable()) {
    642         qWarning("Full Text Search, could not create index (missing permissions).");
     652        qWarning("Full Text Search, could not create index (missing permissions for '%s').", qPrintable(indexPath));
    643653        return;
    644654    }
     
    721731#if !defined(QT_NO_EXCEPTIONS)
    722732    } catch (...) {
    723         qWarning("Full Text Search, could not create index writer.");
     733        qWarning("Full Text Search, could not create index writer in '%s'.",
     734            qPrintable(indexPath));
    724735        return;
    725736    }
    726737#endif
    727738
    728     writer->setMergeFactor(100);
    729     writer->setMinMergeDocs(1000);
    730     writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH);
     739#if !defined(QT_NO_EXCEPTIONS)
     740    try {
     741#endif
     742        writer->setMergeFactor(100);
     743        writer->setMinMergeDocs(1000);
     744        writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH);
     745#if !defined(QT_NO_EXCEPTIONS)
     746    } catch (...) {
     747        qWarning("Full Text Search, could not set writer properties.");
     748        return;
     749    }
     750#endif
    731751
    732752    QStringList namespaces;
     
    734754        mutexLocker.relock();
    735755        if (m_cancel) {
    736             writer->close();
    737             delete writer;
     756            closeIndexWriter(writer);
    738757            emit indexingFinished();
    739758            return;
     
    778797    }
    779798
    780     writer->close();
    781     delete writer;
     799    closeIndexWriter(writer);
    782800
    783801    mutexLocker.relock();
     
    814832        QCLuceneDocument document;
    815833        DocumentHelper helper(url.toString(), engine.fileData(url));
    816         if (helper.addFieldsToDocument(&document, namespaceName, attrList))
    817             writer->addDocument(document, analyzer);
    818 
     834        if (helper.addFieldsToDocument(&document, namespaceName, attrList)) {
     835#if !defined(QT_NO_EXCEPTIONS)
     836            try {
     837#endif
     838                writer->addDocument(document, analyzer);
     839#if !defined(QT_NO_EXCEPTIONS)
     840            } catch (...) {
     841                qWarning("Full Text Search, could not properly add documents.");
     842                return false;
     843            }
     844#endif
     845        }
    819846        locker.relock();
    820847        if (m_cancel)
     
    822849        locker.unlock();
    823850    }
    824 
    825851    return true;
    826852}
     
    862888}
    863889
     890void QHelpSearchIndexWriter::closeIndexWriter(QCLuceneIndexWriter *writer)
     891{
     892#if !defined(QT_NO_EXCEPTIONS)
     893    try {
     894#endif
     895        writer->close();
     896        delete writer;
     897#if !defined(QT_NO_EXCEPTIONS)
     898    } catch (...) {
     899        qWarning("Full Text Search, could not properly close index writer.");
     900    }
     901#endif
     902}
    864903
    865904        }   // namespace clucene
Note: See TracChangeset for help on using the changeset viewer.