forked from qt-creator/qt-creator
Work around QLocalSocket::error deprecation
Centralizing does not bring much benefit here, it's just six locations, and having either a central #include <QLocalSocket> in algorithm.h or a separe file does not sound better. In any case, it is absurd, that deprecating functions to "make code nicer" requires spilling #if QT_VERSION_CHECK over the code. Change-Id: Ia9a8c0eb6ef7cabbaffb46cfe472247e26e7e2c2 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -76,6 +76,13 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
|
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_inputIoDevice(nullptr),
|
m_inputIoDevice(nullptr),
|
||||||
@@ -93,7 +100,7 @@ void NodeInstanceClientProxy::initializeSocket()
|
|||||||
{
|
{
|
||||||
QLocalSocket *localSocket = new QLocalSocket(this);
|
QLocalSocket *localSocket = new QLocalSocket(this);
|
||||||
connect(localSocket, &QIODevice::readyRead, this, &NodeInstanceClientProxy::readDataStream);
|
connect(localSocket, &QIODevice::readyRead, this, &NodeInstanceClientProxy::readDataStream);
|
||||||
connect(localSocket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
connect(localSocket, LocalSocketErrorFunction,
|
||||||
QCoreApplication::instance(), &QCoreApplication::quit);
|
QCoreApplication::instance(), &QCoreApplication::quit);
|
||||||
connect(localSocket, &QLocalSocket::disconnected, QCoreApplication::instance(), &QCoreApplication::quit);
|
connect(localSocket, &QLocalSocket::disconnected, QCoreApplication::instance(), &QCoreApplication::quit);
|
||||||
localSocket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered);
|
localSocket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered);
|
||||||
|
@@ -324,8 +324,15 @@ void ConnectionClient::connectStandardOutputAndError(QProcess *process) const
|
|||||||
|
|
||||||
void ConnectionClient::connectLocalSocketError() const
|
void ConnectionClient::connectLocalSocketError() const
|
||||||
{
|
{
|
||||||
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(m_localSocket,
|
connect(m_localSocket,
|
||||||
QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
LocalSocketErrorFunction,
|
||||||
this,
|
this,
|
||||||
&ConnectionClient::printLocalSocketError);
|
&ConnectionClient::printLocalSocketError);
|
||||||
}
|
}
|
||||||
|
@@ -81,8 +81,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
void connectToLocalServer(const QString &connectionName)
|
void connectToLocalServer(const QString &connectionName)
|
||||||
{
|
{
|
||||||
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
QObject::connect(&m_localSocket,
|
QObject::connect(&m_localSocket,
|
||||||
QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
LocalSocketErrorFunction,
|
||||||
[&] (QLocalSocket::LocalSocketError) {
|
[&] (QLocalSocket::LocalSocketError) {
|
||||||
qWarning() << "ConnectionServer error:" << m_localSocket.errorString() << connectionName;
|
qWarning() << "ConnectionServer error:" << m_localSocket.errorString() << connectionName;
|
||||||
});
|
});
|
||||||
|
@@ -387,8 +387,14 @@ void QmlDebugConnection::newConnection()
|
|||||||
connect(socket, &QLocalSocket::disconnected, this, &QmlDebugConnection::socketDisconnected,
|
connect(socket, &QLocalSocket::disconnected, this, &QmlDebugConnection::socketDisconnected,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
this, [this](QLocalSocket::LocalSocketError error) {
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
connect(socket, LocalSocketErrorFunction, this, [this](QLocalSocket::LocalSocketError error) {
|
||||||
emit logError(socketErrorToString(static_cast<QAbstractSocket::SocketError>(error)));
|
emit logError(socketErrorToString(static_cast<QAbstractSocket::SocketError>(error)));
|
||||||
socketDisconnected();
|
socketDisconnected();
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
@@ -62,11 +62,17 @@ void QdbWatcher::start(RequestType requestType)
|
|||||||
|
|
||||||
void QdbWatcher::startPrivate()
|
void QdbWatcher::startPrivate()
|
||||||
{
|
{
|
||||||
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_socket = std::unique_ptr<QLocalSocket>(new QLocalSocket());
|
m_socket = std::unique_ptr<QLocalSocket>(new QLocalSocket());
|
||||||
connect(m_socket.get(), &QLocalSocket::connected,
|
connect(m_socket.get(), &QLocalSocket::connected,
|
||||||
this, &QdbWatcher::handleWatchConnection);
|
this, &QdbWatcher::handleWatchConnection);
|
||||||
connect(m_socket.get(), static_cast<void (QLocalSocket::*)
|
connect(m_socket.get(), LocalSocketErrorFunction,
|
||||||
(QLocalSocket::LocalSocketError)>(&QLocalSocket::error),
|
|
||||||
this, &QdbWatcher::handleWatchError);
|
this, &QdbWatcher::handleWatchError);
|
||||||
m_socket->connectToServer(qdbSocketName);
|
m_socket->connectToServer(qdbSocketName);
|
||||||
}
|
}
|
||||||
|
@@ -207,8 +207,15 @@ void ServerMode::connectToServer()
|
|||||||
|
|
||||||
auto socket = new QLocalSocket(m_cmakeProcess.get());
|
auto socket = new QLocalSocket(m_cmakeProcess.get());
|
||||||
connect(socket, &QLocalSocket::readyRead, this, &ServerMode::handleRawCMakeServerData);
|
connect(socket, &QLocalSocket::readyRead, this, &ServerMode::handleRawCMakeServerData);
|
||||||
connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
|
||||||
this, [this, socket]() {
|
constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
= &QLocalSocket::error;
|
||||||
|
#else
|
||||||
|
= &QLocalSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
connect(socket, LocalSocketErrorFunction, this, [this, socket]() {
|
||||||
reportError(socket->errorString());
|
reportError(socket->errorString());
|
||||||
m_cmakeSocket = nullptr;
|
m_cmakeSocket = nullptr;
|
||||||
socket->disconnect();
|
socket->disconnect();
|
||||||
|
Reference in New Issue
Block a user