forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user