forked from qt-creator/qt-creator
QmakePM: Replace QSignalMapper with a lambda
Change-Id: Iea656322c56f31f6958d3d497f98fc3bcb424c78 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
8e833db5a6
commit
a48acdff52
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSignalMapper>
|
|
||||||
|
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
@@ -261,24 +260,17 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error
|
|||||||
|
|
||||||
if (!startEditorProcess(data, errorMessage))
|
if (!startEditorProcess(data, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
// Set up signal mapper to track process termination via socket
|
|
||||||
if (!m_terminationMapper) {
|
|
||||||
m_terminationMapper = new QSignalMapper(this);
|
|
||||||
connect(m_terminationMapper,
|
|
||||||
static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
|
|
||||||
this, &DesignerExternalEditor::processTerminated);
|
|
||||||
}
|
|
||||||
// Insert into cache if socket is created, else try again next time
|
// Insert into cache if socket is created, else try again next time
|
||||||
if (server.waitForNewConnection(3000)) {
|
if (server.waitForNewConnection(3000)) {
|
||||||
QTcpSocket *socket = server.nextPendingConnection();
|
QTcpSocket *socket = server.nextPendingConnection();
|
||||||
socket->setParent(this);
|
socket->setParent(this);
|
||||||
m_processCache.insert(data.binary, socket);
|
const QString binary = data.binary;
|
||||||
m_terminationMapper->setMapping(socket, data.binary);
|
m_processCache.insert(binary, socket);
|
||||||
auto mapSlot = static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map);
|
auto mapSlot = [this, binary] { processTerminated(binary); };
|
||||||
connect(socket, &QAbstractSocket::disconnected, m_terminationMapper, mapSlot);
|
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
||||||
connect(socket,
|
connect(socket,
|
||||||
static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
|
static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
|
||||||
m_terminationMapper, mapSlot);
|
this, mapSlot);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QProcess;
|
class QProcess;
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
class QSignalMapper;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QtSupport { class BaseQtVersion; }
|
namespace QtSupport { class BaseQtVersion; }
|
||||||
@@ -132,7 +131,6 @@ private:
|
|||||||
typedef QMap<QString, QTcpSocket*> ProcessCache;
|
typedef QMap<QString, QTcpSocket*> ProcessCache;
|
||||||
|
|
||||||
ProcessCache m_processCache;
|
ProcessCache m_processCache;
|
||||||
QSignalMapper *m_terminationMapper = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user