- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the Qt Assistant of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 431 431 { 432 432 QTextStream textStream(data); 433 QByteArray charSet = QHelpGlobal::charsetFromData(data).toLatin1();434 textStream.setCodec(QTextCodec::codecForName(c harSet.constData()));433 const QByteArray &codec = QHelpGlobal::codecFromData(data).toLatin1(); 434 textStream.setCodec(QTextCodec::codecForName(codec.constData())); 435 435 436 436 QString stream = textStream.readAll(); … … 579 579 const QString &indexFilesFolder, bool reindex) 580 580 { 581 wait(); 581 582 mutex.lock(); 582 583 this->m_cancel = false; … … 591 592 void QHelpSearchIndexWriter::optimizeIndex() 592 593 { 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 602 612 } 603 613 … … 640 650 QFileInfo fInfo(indexPath); 641 651 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)); 643 653 return; 644 654 } … … 721 731 #if !defined(QT_NO_EXCEPTIONS) 722 732 } 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)); 724 735 return; 725 736 } 726 737 #endif 727 738 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 731 751 732 752 QStringList namespaces; … … 734 754 mutexLocker.relock(); 735 755 if (m_cancel) { 736 writer->close(); 737 delete writer; 756 closeIndexWriter(writer); 738 757 emit indexingFinished(); 739 758 return; … … 778 797 } 779 798 780 writer->close(); 781 delete writer; 799 closeIndexWriter(writer); 782 800 783 801 mutexLocker.relock(); … … 814 832 QCLuceneDocument document; 815 833 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 } 819 846 locker.relock(); 820 847 if (m_cancel) … … 822 849 locker.unlock(); 823 850 } 824 825 851 return true; 826 852 } … … 862 888 } 863 889 890 void 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 } 864 903 865 904 } // namespace clucene
Note:
See TracChangeset
for help on using the changeset viewer.