AutotoolsBuildSystem: Avoid using sender()

According to the old explanation inside makefileParsingFinished()
the solution of using sender() can't work reliably in this
case. In scenarion where the old, deleted m_makefileParserThread
had the same address as newly allocated one we might not detect
correctly posted finished() signal of the deleted object.
According to QObject::sender() documentation:
"The pointer returned by this function becomes invalid if the
sender is destroyed", so we can't rely on its value.

Instead, add a new done() signal to the MakefileParserThread,
which is being emitted from MakefileParserThread thread (i.e. from
the thread where MakefileParserThread object lives in). In this way
the finished() signal is still posted to the caller's thread,
but this time if the MakefileParserThread object is already
deleted, the finished() signal will be gone together with the
MakefileParserThread object itself, so we also won't receive done()
signal anymore.

Simplify the internals by using std::unique_ptr.

Change-Id: I43be209ecb71539ddefd72e50e9d60bfb43c49cb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2022-07-21 17:48:49 +02:00
parent 10da5083fe
commit f6b37328c7
4 changed files with 23 additions and 37 deletions

View File

@@ -131,6 +131,13 @@ signals:
*/
void status(const QString &status);
/**
* Similar to finished, but emitted from MakefileParserThread thread, i.e. from the
* thread where the MakefileParserThread lives in, not the tread that it creates.
* This helps to avoid race condition when connecting to finished() signal.
*/
void done();
private:
MakefileParser m_parser; ///< Is not accessible outside the thread