QmakePM: Replace QSignalMapper with a lambda

Change-Id: Iea656322c56f31f6958d3d497f98fc3bcb424c78
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-19 23:22:41 +03:00
committed by Orgad Shaneh
parent 8e833db5a6
commit a48acdff52
2 changed files with 5 additions and 15 deletions

View File

@@ -37,7 +37,6 @@
#include <QProcess>
#include <QDebug>
#include <QSignalMapper>
#include <QTcpSocket>
#include <QTcpServer>
@@ -261,24 +260,17 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error
if (!startEditorProcess(data, errorMessage))
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
if (server.waitForNewConnection(3000)) {
QTcpSocket *socket = server.nextPendingConnection();
socket->setParent(this);
m_processCache.insert(data.binary, socket);
m_terminationMapper->setMapping(socket, data.binary);
auto mapSlot = static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map);
connect(socket, &QAbstractSocket::disconnected, m_terminationMapper, mapSlot);
const QString binary = data.binary;
m_processCache.insert(binary, socket);
auto mapSlot = [this, binary] { processTerminated(binary); };
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
connect(socket,
static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
m_terminationMapper, mapSlot);
this, mapSlot);
}
return true;
}

View File

@@ -34,7 +34,6 @@
QT_BEGIN_NAMESPACE
class QProcess;
class QTcpSocket;
class QSignalMapper;
QT_END_NAMESPACE
namespace QtSupport { class BaseQtVersion; }
@@ -132,7 +131,6 @@ private:
typedef QMap<QString, QTcpSocket*> ProcessCache;
ProcessCache m_processCache;
QSignalMapper *m_terminationMapper = nullptr;
};
} // namespace Internal