summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-09-19 11:48:07 (GMT)
committerChristian Kandeler <christian.kandeler@digia.com>2014-09-19 14:19:39 (GMT)
commit10ddcc93c15d2c7bd5126fdb9ed217eb496cc387 (patch)
treefcab8c6ef93526cff5809d8a881a4f546e31ff00
parent922c87a3b8ab16b18b2f04c114f6d20ba12e4eb9 (diff)
downloadQt-10ddcc93c15d2c7bd5126fdb9ed217eb496cc387.zip
Qt-10ddcc93c15d2c7bd5126fdb9ed217eb496cc387.tar.gz
Qt-10ddcc93c15d2c7bd5126fdb9ed217eb496cc387.tar.bz2
Fix crash when accessing the content model.
1) Make sure invalidateContents() is called whenever the help engine's DB readers are destroyed. 2) In QHelpContentProvider::stopCollecting(), remove all root items, as they are invalid now: Their child items reference DB readers that are going to be destroyed. Task-number: QTBUG-18829 Change-Id: Iab3245eb9fd405f28105aa08a976d9a108b9c70a Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
-rw-r--r--tools/assistant/lib/qhelpcontentwidget.cpp20
-rw-r--r--tools/assistant/lib/qhelpenginecore.cpp1
-rw-r--r--tools/assistant/lib/qhelpenginecore.h1
-rw-r--r--tools/assistant/lib/qhelpindexwidget.cpp2
4 files changed, 16 insertions, 8 deletions
diff --git a/tools/assistant/lib/qhelpcontentwidget.cpp b/tools/assistant/lib/qhelpcontentwidget.cpp
index e183c41..8697cdf 100644
--- a/tools/assistant/lib/qhelpcontentwidget.cpp
+++ b/tools/assistant/lib/qhelpcontentwidget.cpp
@@ -219,22 +219,28 @@ void QHelpContentProvider::collectContents(const QString &customFilterName)
void QHelpContentProvider::stopCollecting()
{
- if (!isRunning())
- return;
- m_mutex.lock();
- m_abort = true;
- m_mutex.unlock();
- wait();
+ if (isRunning()) {
+ m_mutex.lock();
+ m_abort = true;
+ m_mutex.unlock();
+ wait();
+ }
+ qDeleteAll(m_rootItems);
+ m_rootItems.clear();
}
QHelpContentItem *QHelpContentProvider::rootItem()
{
QMutexLocker locker(&m_mutex);
+ if (m_rootItems.isEmpty())
+ return 0;
return m_rootItems.dequeue();
}
int QHelpContentProvider::nextChildCount() const
{
+ if (m_rootItems.isEmpty())
+ return 0;
return m_rootItems.head()->childCount();
}
@@ -348,7 +354,7 @@ QHelpContentModel::QHelpContentModel(QHelpEnginePrivate *helpEngine)
connect(d->qhelpContentProvider, SIGNAL(finished()),
this, SLOT(insertContents()), Qt::QueuedConnection);
- connect(helpEngine->q, SIGNAL(setupStarted()), this, SLOT(invalidateContents()));
+ connect(helpEngine->q, SIGNAL(readersAboutToBeInvalidated()), this, SLOT(invalidateContents()));
}
/*!
diff --git a/tools/assistant/lib/qhelpenginecore.cpp b/tools/assistant/lib/qhelpenginecore.cpp
index f141517..8c034cf 100644
--- a/tools/assistant/lib/qhelpenginecore.cpp
+++ b/tools/assistant/lib/qhelpenginecore.cpp
@@ -79,6 +79,7 @@ QHelpEngineCorePrivate::~QHelpEngineCorePrivate()
void QHelpEngineCorePrivate::clearMaps()
{
+ emit q->readersAboutToBeInvalidated();
QMap<QString, QHelpDBReader*>::iterator it = readerMap.begin();
while (it != readerMap.end()) {
delete it.value();
diff --git a/tools/assistant/lib/qhelpenginecore.h b/tools/assistant/lib/qhelpenginecore.h
index 72be47f..6733aec 100644
--- a/tools/assistant/lib/qhelpenginecore.h
+++ b/tools/assistant/lib/qhelpenginecore.h
@@ -119,6 +119,7 @@ Q_SIGNALS:
void setupFinished();
void currentFilterChanged(const QString &newFilter);
void warning(const QString &msg);
+ void readersAboutToBeInvalidated();
protected:
QHelpEngineCore(QHelpEngineCorePrivate *helpEngineCorePrivate,
diff --git a/tools/assistant/lib/qhelpindexwidget.cpp b/tools/assistant/lib/qhelpindexwidget.cpp
index a50f688..98530f7 100644
--- a/tools/assistant/lib/qhelpindexwidget.cpp
+++ b/tools/assistant/lib/qhelpindexwidget.cpp
@@ -230,7 +230,7 @@ QHelpIndexModel::QHelpIndexModel(QHelpEnginePrivate *helpEngine)
d = new QHelpIndexModelPrivate(helpEngine);
connect(d->indexProvider, SIGNAL(finished()), this, SLOT(insertIndices()));
- connect(helpEngine->q, SIGNAL(setupStarted()), this, SLOT(invalidateIndex()));
+ connect(helpEngine->q, SIGNAL(readersAboutToBeInvalidated()), this, SLOT(invalidateIndex()));
}
QHelpIndexModel::~QHelpIndexModel()