AutoTest: Avoid dead-lock of file system watcher

Calling addPath() on the watcher could dead-lock on some operating
systems as we were in an asynchronous process.
Avoid calling addPath() from inside an asynchronous process and
perform this call from synchronous context.

Change-Id: I94cd401e12ccbb3526b8cc4232a9cff7ed552bbb
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-03-20 15:42:08 +01:00
parent 4bdfebb4dd
commit b86011c375
2 changed files with 29 additions and 21 deletions

View File

@@ -29,6 +29,8 @@
#include <qmljs/qmljsdocument.h>
#include <QFileSystemWatcher>
namespace Autotest {
namespace Internal {
@@ -39,8 +41,9 @@ public:
TestTreeItem *createTestTreeItem() const override;
};
class QuickTestParser : public CppParser
class QuickTestParser : public QObject, public CppParser
{
Q_OBJECT
public:
QuickTestParser();
virtual ~QuickTestParser();
@@ -48,9 +51,15 @@ public:
void release() override;
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
const QString &fileName) override;
signals:
void updateWatchPaths(const QStringList &directories) const;
private:
bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterface,
CPlusPlus::Document::Ptr document, const Core::Id &id) const;
QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QString &srcDir) const;
QmlJS::Snapshot m_qmlSnapshot;
QHash<QString, QString> m_proFilesForQmlFiles;
QFileSystemWatcher m_directoryWatcher;
};
} // namespace Internal