Enable exceptions code, makes Assistant far more stable.
authorkh1 <karsten.heimrich@digia.com>
Fri, 14 Dec 2012 13:29:00 +0000 (14:29 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 17 Dec 2012 13:07:54 +0000 (14:07 +0100)
Task-number: QTBUG-28592

The reason to enable exceptions (always) is that we build the
full text engine with exceptions as well, which throws erratic.
Once it does that the database it creates is in a unknow state,
which leads to new exceptions on next Assistant start. So it will
never start again until someone removes the broken index by hand.

Change-Id: Ic24a9e28bddf4657753f9b670c38ecda527d7af4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
src/assistant/help/help.pro
src/assistant/help/qhelpsearchindexreader_clucene.cpp
src/assistant/help/qhelpsearchindexwriter_clucene.cpp

index ffdac1b..ed75c37 100644 (file)
@@ -10,6 +10,20 @@ load(qt_module)
 
 DEFINES -= QT_ASCII_CAST_WARNINGS
 
+# impossible to disable exceptions in clucene atm and use help lib without
+CONFIG(exceptions_off) {
+    CONFIG -= exceptions_off
+    CONFIG += exceptions
+    !win32|win32-g++* {
+        QMAKE_CFLAGS -= -fno-exceptions
+        QMAKE_CXXFLAGS -= -fno-exceptions
+        QMAKE_LFLAGS -= -fno-exceptions
+        QMAKE_CFLAGS += -fexceptions
+        QMAKE_CXXFLAGS += -fexceptions
+        QMAKE_LFLAGS += -fexceptions
+    }
+}
+
 RESOURCES += helpsystem.qrc
 SOURCES += qhelpenginecore.cpp \
     qhelpengine.cpp \
index b1172f2..1221b38 100644 (file)
@@ -107,9 +107,7 @@ void QHelpSearchIndexReaderClucene::run()
 
         emit searchingStarted();
 
-#if !defined(QT_NO_EXCEPTIONS)
         try {
-#endif
             QCLuceneBooleanQuery booleanQueryTitle;
             QCLuceneBooleanQuery booleanQueryContent;
             QCLuceneStandardAnalyzer analyzer;
@@ -199,15 +197,12 @@ void QHelpSearchIndexReaderClucene::run()
             if ((count > 0) && boost)
                 boostSearchHits(engine, hitList, queryList);
             emit searchingFinished(hitList.count());
-
-#if !defined(QT_NO_EXCEPTIONS)
         } catch(...) {
             mutex.lock();
             hitList.clear();
             mutex.unlock();
             emit searchingFinished(0);
         }
-#endif
     }
 }
 
index 1c5d13a..c70d5ec 100644 (file)
@@ -591,9 +591,7 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile,
 
 void QHelpSearchIndexWriter::optimizeIndex()
 {
-#if !defined(QT_NO_EXCEPTIONS)
     try {
-#endif
         if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) {
             if (QCLuceneIndexReader::isLocked(m_indexFilesFolder))
                 return;
@@ -603,19 +601,15 @@ void QHelpSearchIndexWriter::optimizeIndex()
             writer.optimize();
             writer.close();
         }
-#if !defined(QT_NO_EXCEPTIONS)
     } catch (...) {
         qWarning("Full Text Search, could not optimize index.");
         return;
     }
-#endif
 }
 
 void QHelpSearchIndexWriter::run()
 {
-#if !defined(QT_NO_EXCEPTIONS)
     try {
-#endif
         QMutexLocker mutexLocker(&mutex);
 
         if (m_cancel)
@@ -801,13 +795,9 @@ void QHelpSearchIndexWriter::run()
                 }
             }
         }
-
-#if !defined(QT_NO_EXCEPTIONS)
     } catch (...) {
         qWarning("%s: Failed because of CLucene exception.", Q_FUNC_INFO);
     }
-#endif
-
     emit indexingFinished();
 }
 
@@ -824,16 +814,12 @@ bool QHelpSearchIndexWriter::addDocuments(const QList<QUrl> docFiles,
         QCLuceneDocument document;
         DocumentHelper helper(url.toString(), engine.fileData(url));
         if (helper.addFieldsToDocument(&document, namespaceName, attrList)) {
-#if !defined(QT_NO_EXCEPTIONS)
             try {
-#endif
                 writer->addDocument(document, analyzer);
-#if !defined(QT_NO_EXCEPTIONS)
             } catch (...) {
                 qWarning("Full Text Search, could not properly add documents.");
                 return false;
             }
-#endif
         }
         locker.relock();
         if (m_cancel)
@@ -880,16 +866,12 @@ QList<QUrl> QHelpSearchIndexWriter::indexableFiles(QHelpEngineCore *helpEngine,
 
 void QHelpSearchIndexWriter::closeIndexWriter(QCLuceneIndexWriter *writer)
 {
-#if !defined(QT_NO_EXCEPTIONS)
     try {
-#endif
         writer->close();
         delete writer;
-#if !defined(QT_NO_EXCEPTIONS)
     } catch (...) {
         qWarning("Full Text Search, could not properly close index writer.");
     }
-#endif
 }
 
 }   // namespace clucene