Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/cmake/cmakeserver.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 50 | #endif | |||
---|---|---|---|---|---|
60 | connect(m_localSocket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), this, [this, path](QLocalSocket::LocalSocketError socketError) { | 60 | connect(m_localSocket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), this, [this, path](QLocalSocket::LocalSocketError socketError) { | ||
61 | qCWarning(CMAKE) << "cmake server socket error:" << socketError << path; | 61 | qCWarning(CMAKE) << "cmake server socket error:" << socketError << path; | ||
62 | setConnected(false); | 62 | setConnected(false); | ||
63 | }); | 63 | }); | ||
64 | connect(m_localSocket, &QLocalSocket::connected, this, [this]() { setConnected(true); }); | 64 | connect(m_localSocket, &QLocalSocket::connected, this, [this]() { setConnected(true); }); | ||
65 | 65 | | |||
66 | connect(&m_process, &QProcess::started, this, [this, path](){ | 66 | connect(&m_process, &QProcess::started, this, [this, path](){ | ||
67 | //Once the process has started, wait for the file to be created, then connect to it | 67 | //Once the process has started, wait for the file to be created, then connect to it | ||
68 | m_localSocket->connectToServer(path, QIODevice::ReadWrite); | | |||
69 | QTimer::singleShot(100, this, [this, path]() { | 68 | QTimer::singleShot(100, this, [this, path]() { | ||
70 | if (!m_localSocket->isOpen()) | | |||
71 | m_localSocket->connectToServer(path, QIODevice::ReadWrite); | 69 | m_localSocket->connectToServer(path, QIODevice::ReadWrite); | ||
72 | }); | 70 | }); | ||
73 | }); | 71 | }); | ||
74 | m_process.start(CMake::findExecutable(), {"-E", "server", "--experimental", "--pipe=" + path}); | 72 | m_process.start(CMake::findExecutable(), {"-E", "server", "--experimental", "--pipe=" + path}); | ||
75 | } | 73 | } | ||
76 | 74 | | |||
77 | CMakeServer::~CMakeServer() | 75 | CMakeServer::~CMakeServer() | ||
78 | { | 76 | { | ||
77 | m_process.disconnect(); | ||||
rjvbb: Is it certain that we aren't disconnecting QObject::destroyed signals here that should not be… | |||||
79 | m_process.kill(); | 78 | m_process.kill(); | ||
80 | m_process.waitForFinished(); | 79 | m_process.waitForFinished(); | ||
81 | } | 80 | } | ||
82 | 81 | | |||
83 | void CMakeServer::setConnected(bool conn) | 82 | void CMakeServer::setConnected(bool conn) | ||
84 | { | 83 | { | ||
85 | if (conn == m_connected) | 84 | if (conn == m_connected) | ||
86 | return; | 85 | return; | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
Is it certain that we aren't disconnecting QObject::destroyed signals here that should not be disconnected before m_process is actually destroyed?
I too did a disconnect() in a dtor thinking it was a prudent thing to do. All was fine for months until I ran into an application that crashed systematically on exit, accessing a stale QObject.