ClassView: Delete Parser object from inside parser's thread

The Parser object is being moved to parser's thread inside
Manager constructor. However, when destructor of Manager
is being called, we delete the Parser from inside the main
thread. According to QThread documentation we should delete
object (which have been moved to another thread) from inside
the object's current thread. So in case of Parser, we should
delete it from the parser's thread. In order to fix it,
we create Parser object dynamically and connect finished
signal of the parser's thread to the parser's deleteLater().
Since now the parser is being deleted in parser's thread
we don't need a special handling for stopping the timer
object inside the parser's thread, as its destructor
will also be called from inside parser's thread.

Task-number: QTCREATORBUG-25317
Change-Id: I28dee2c3db5cf8329a9578e7a85952e8a85850d3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-16 17:44:28 +01:00
parent 8c5dc305ae
commit 72f727b6ac
3 changed files with 17 additions and 28 deletions

View File

@@ -88,7 +88,6 @@ public:
CPlusPlus::Document::Ptr document(const QString &fileName) const;
QTimer timer;
bool m_shuttingDown = false;
struct DocumentCache {
unsigned treeRevision = 0;
@@ -160,12 +159,6 @@ void Parser::setFlatMode(bool flatMode)
requestCurrentState();
}
void Parser::aboutToShutdown()
{
d->m_shuttingDown = true;
d->timer.stop();
}
/*!
Parses the class and produces a new tree.
@@ -331,7 +324,7 @@ void Parser::parseDocument(const CPlusPlus::Document::Ptr &doc)
getParseDocumentTree(doc);
if (!d->timer.isActive() && !d->m_shuttingDown)
if (!d->timer.isActive())
d->timer.start(400); //! Delay in msecs before an update
}