forked from qt-creator/qt-creator
Base unique tokens on global atomic counter
Don't base process token on instance pointer, as it may happen that the recreated instance may get the same token again (it happens often when invoking a function that recreates QtcProcess in sequence). The consequence may be that on the project launcher side we may reuse the old process (with possibly broken state) instead of creating a new one. Change-Id: I8274691f88ae0eefe008746d944a26f29979bf72 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -275,11 +275,17 @@ private:
|
|||||||
ProcessHelper m_process;
|
ProcessHelper m_process;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint uniqueToken()
|
||||||
|
{
|
||||||
|
static std::atomic_uint globalUniqueToken = 0;
|
||||||
|
return ++globalUniqueToken;
|
||||||
|
}
|
||||||
|
|
||||||
class ProcessLauncherImpl : public ProcessInterface
|
class ProcessLauncherImpl : public ProcessInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProcessLauncherImpl() : ProcessInterface()
|
ProcessLauncherImpl() : ProcessInterface(), m_token(uniqueToken())
|
||||||
{
|
{
|
||||||
m_handle = LauncherInterface::socket()->registerHandle(token());
|
m_handle = LauncherInterface::socket()->registerHandle(token());
|
||||||
connect(m_handle, &LauncherHandle::errorOccurred,
|
connect(m_handle, &LauncherHandle::errorOccurred,
|
||||||
@@ -351,8 +357,9 @@ private:
|
|||||||
void handleSocketError(const QString &message);
|
void handleSocketError(const QString &message);
|
||||||
void handleSocketReady();
|
void handleSocketReady();
|
||||||
|
|
||||||
quintptr token() const { return reinterpret_cast<quintptr>(this); }
|
quintptr token() const { return m_token; }
|
||||||
|
|
||||||
|
const uint m_token = 0;
|
||||||
LauncherHandle *m_handle = nullptr; // This object lives in a different thread!
|
LauncherHandle *m_handle = nullptr; // This object lives in a different thread!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user