Enable compilation of qtbase with localserver off
Since we will need to turn off this feature for certain platforms, code must compile with QT_FEATURE_localserver turned off, which now can't. Fix this by disabling parts of code requiring QT_FEATURE_localserver. Task-number: QTBUG-115777 Change-Id: I6d78030db67ee679d6877b48a437db90a6e47a02 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 5bbb05c72c8b8f2d33beae722a704a1c293a55ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6a2035d970
commit
0c4f0b557e
@ -112,10 +112,12 @@ void QHttpNetworkConnectionPrivate::pauseConnection()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
QAbstractSocketPrivate::pauseSocketNotifiers(absSocket);
|
QAbstractSocketPrivate::pauseSocketNotifiers(absSocket);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if (qobject_cast<QLocalSocket *>(channels[i].socket)) {
|
} else if (qobject_cast<QLocalSocket *>(channels[i].socket)) {
|
||||||
// @todo how would we do this?
|
// @todo how would we do this?
|
||||||
#if 0 // @todo Enable this when there is a debug category for this
|
#if 0 // @todo Enable this when there is a debug category for this
|
||||||
qDebug() << "Should pause socket but there is no way to do it for local sockets";
|
qDebug() << "Should pause socket but there is no way to do it for local sockets";
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,9 +139,11 @@ void QHttpNetworkConnectionPrivate::resumeConnection()
|
|||||||
// Resume pending upload if needed
|
// Resume pending upload if needed
|
||||||
if (channels[i].state == QHttpNetworkConnectionChannel::WritingState)
|
if (channels[i].state == QHttpNetworkConnectionChannel::WritingState)
|
||||||
QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if (qobject_cast<QLocalSocket *>(channels[i].socket)) {
|
} else if (qobject_cast<QLocalSocket *>(channels[i].socket)) {
|
||||||
#if 0 // @todo Enable this when there is a debug category for this
|
#if 0 // @todo Enable this when there is a debug category for this
|
||||||
qDebug() << "Should resume socket but there is no way to do it for local sockets";
|
qDebug() << "Should resume socket but there is no way to do it for local sockets";
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "private/qnetconmonitor_p.h"
|
#include "private/qnetconmonitor_p.h"
|
||||||
|
|
||||||
|
#include <QtNetwork/private/qtnetworkglobal_p.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -79,8 +81,10 @@ void QHttpNetworkConnectionChannel::init()
|
|||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
if (connection->d_func()->encrypt)
|
if (connection->d_func()->encrypt)
|
||||||
socket = new QSslSocket;
|
socket = new QSslSocket;
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
else if (connection->d_func()->isLocalSocket)
|
else if (connection->d_func()->isLocalSocket)
|
||||||
socket = new QLocalSocket;
|
socket = new QLocalSocket;
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
socket = new QTcpSocket;
|
socket = new QTcpSocket;
|
||||||
#else
|
#else
|
||||||
@ -122,6 +126,7 @@ void QHttpNetworkConnectionChannel::init()
|
|||||||
QObject::connect(socket, &QAbstractSocket::errorOccurred,
|
QObject::connect(socket, &QAbstractSocket::errorOccurred,
|
||||||
this, &QHttpNetworkConnectionChannel::_q_error,
|
this, &QHttpNetworkConnectionChannel::_q_error,
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if constexpr (std::is_same_v<SocketType, QLocalSocket>) {
|
} else if constexpr (std::is_same_v<SocketType, QLocalSocket>) {
|
||||||
auto convertAndForward = [this](QLocalSocket::LocalSocketError error) {
|
auto convertAndForward = [this](QLocalSocket::LocalSocketError error) {
|
||||||
_q_error(static_cast<QAbstractSocket::SocketError>(error));
|
_q_error(static_cast<QAbstractSocket::SocketError>(error));
|
||||||
@ -129,6 +134,7 @@ void QHttpNetworkConnectionChannel::init()
|
|||||||
QObject::connect(socket, &SocketType::errorOccurred,
|
QObject::connect(socket, &SocketType::errorOccurred,
|
||||||
this, std::move(convertAndForward),
|
this, std::move(convertAndForward),
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, socket);
|
}, socket);
|
||||||
|
|
||||||
@ -437,8 +443,10 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
|
|||||||
networkLayerPreference);
|
networkLayerPreference);
|
||||||
// For an Unbuffered QTcpSocket, the read buffer size has a special meaning.
|
// For an Unbuffered QTcpSocket, the read buffer size has a special meaning.
|
||||||
s->setReadBufferSize(1 * 1024);
|
s->setReadBufferSize(1 * 1024);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if (auto *s = qobject_cast<QLocalSocket *>(socket)) {
|
} else if (auto *s = qobject_cast<QLocalSocket *>(socket)) {
|
||||||
s->connectToServer(connectHost);
|
s->connectToServer(connectHost);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifndef QT_NO_NETWORKPROXY
|
#ifndef QT_NO_NETWORKPROXY
|
||||||
} else {
|
} else {
|
||||||
@ -984,6 +992,7 @@ void QHttpNetworkConnectionChannel::_q_connected_abstract_socket(QAbstractSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
void QHttpNetworkConnectionChannel::_q_connected_local_socket(QLocalSocket *localSocket)
|
void QHttpNetworkConnectionChannel::_q_connected_local_socket(QLocalSocket *localSocket)
|
||||||
{
|
{
|
||||||
state = QHttpNetworkConnectionChannel::IdleState;
|
state = QHttpNetworkConnectionChannel::IdleState;
|
||||||
@ -992,13 +1001,16 @@ void QHttpNetworkConnectionChannel::_q_connected_local_socket(QLocalSocket *loca
|
|||||||
if (reply)
|
if (reply)
|
||||||
sendRequest();
|
sendRequest();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QHttpNetworkConnectionChannel::_q_connected()
|
void QHttpNetworkConnectionChannel::_q_connected()
|
||||||
{
|
{
|
||||||
if (auto *s = qobject_cast<QAbstractSocket *>(socket))
|
if (auto *s = qobject_cast<QAbstractSocket *>(socket))
|
||||||
_q_connected_abstract_socket(s);
|
_q_connected_abstract_socket(s);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
else if (auto *s = qobject_cast<QLocalSocket *>(socket))
|
else if (auto *s = qobject_cast<QLocalSocket *>(socket))
|
||||||
_q_connected_local_socket(s);
|
_q_connected_local_socket(s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socketError)
|
void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socketError)
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <QtNetwork/qnetworkrequest.h>
|
#include <QtNetwork/qnetworkrequest.h>
|
||||||
#include <QtNetwork/qnetworkreply.h>
|
#include <QtNetwork/qnetworkreply.h>
|
||||||
#include <QtNetwork/qabstractsocket.h>
|
#include <QtNetwork/qabstractsocket.h>
|
||||||
#include <QtNetwork/qlocalsocket.h>
|
|
||||||
|
|
||||||
#include <private/qobject_p.h>
|
#include <private/qobject_p.h>
|
||||||
#include <qauthenticator.h>
|
#include <qauthenticator.h>
|
||||||
@ -40,6 +39,10 @@
|
|||||||
#else
|
#else
|
||||||
# include <QtNetwork/qtcpsocket.h>
|
# include <QtNetwork/qtcpsocket.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
|
# include <QtNetwork/qlocalsocket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
#include <QtCore/qscopedpointer.h>
|
#include <QtCore/qscopedpointer.h>
|
||||||
@ -164,7 +167,9 @@ public:
|
|||||||
void _q_readyRead(); // pending data to read
|
void _q_readyRead(); // pending data to read
|
||||||
void _q_disconnected(); // disconnected from host
|
void _q_disconnected(); // disconnected from host
|
||||||
void _q_connected_abstract_socket(QAbstractSocket *socket);
|
void _q_connected_abstract_socket(QAbstractSocket *socket);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
void _q_connected_local_socket(QLocalSocket *socket);
|
void _q_connected_local_socket(QLocalSocket *socket);
|
||||||
|
#endif
|
||||||
void _q_connected(); // start sending request
|
void _q_connected(); // start sending request
|
||||||
void _q_error(QAbstractSocket::SocketError); // error from socket
|
void _q_error(QAbstractSocket::SocketError); // error from socket
|
||||||
#ifndef QT_NO_NETWORKPROXY
|
#ifndef QT_NO_NETWORKPROXY
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <private/qtnetworkglobal_p.h>
|
#include <private/qtnetworkglobal_p.h>
|
||||||
|
|
||||||
#include <QtNetwork/qabstractsocket.h>
|
#include <QtNetwork/qabstractsocket.h>
|
||||||
#include <QtNetwork/qlocalsocket.h>
|
#if QT_CONFIG(localserver)
|
||||||
|
# include <QtNetwork/qlocalsocket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QtCore/qxpfunctional.h>
|
#include <QtCore/qxpfunctional.h>
|
||||||
|
|
||||||
@ -32,8 +34,10 @@ auto visit(Fn &&fn, QIODevice *socket, Args &&...args)
|
|||||||
{
|
{
|
||||||
if (auto *s = qobject_cast<QAbstractSocket *>(socket))
|
if (auto *s = qobject_cast<QAbstractSocket *>(socket))
|
||||||
return std::forward<Fn>(fn)(s, std::forward<Args>(args)...);
|
return std::forward<Fn>(fn)(s, std::forward<Args>(args)...);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
if (auto *s = qobject_cast<QLocalSocket *>(socket))
|
if (auto *s = qobject_cast<QLocalSocket *>(socket))
|
||||||
return std::forward<Fn>(fn)(s, std::forward<Args>(args)...);
|
return std::forward<Fn>(fn)(s, std::forward<Args>(args)...);
|
||||||
|
#endif
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,9 +50,11 @@ inline QAbstractSocket::SocketState socketState(QIODevice *device)
|
|||||||
using T = std::remove_pointer_t<decltype(s)>;
|
using T = std::remove_pointer_t<decltype(s)>;
|
||||||
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
||||||
return s->state();
|
return s->state();
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
||||||
QLocalSocket::LocalSocketState st = s->state();
|
QLocalSocket::LocalSocketState st = s->state();
|
||||||
return static_cast<QAbstractSocket::SocketState>(st);
|
return static_cast<QAbstractSocket::SocketState>(st);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
};
|
};
|
||||||
@ -62,9 +68,11 @@ inline QAbstractSocket::SocketError socketError(QIODevice *device)
|
|||||||
using T = std::remove_pointer_t<decltype(s)>;
|
using T = std::remove_pointer_t<decltype(s)>;
|
||||||
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
||||||
return s->error();
|
return s->error();
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
||||||
QLocalSocket::LocalSocketError st = s->error();
|
QLocalSocket::LocalSocketError st = s->error();
|
||||||
return static_cast<QAbstractSocket::SocketError>(st);
|
return static_cast<QAbstractSocket::SocketError>(st);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
};
|
};
|
||||||
@ -77,8 +85,10 @@ inline QString socketPeerName(QIODevice *device)
|
|||||||
using T = std::remove_pointer_t<decltype(s)>;
|
using T = std::remove_pointer_t<decltype(s)>;
|
||||||
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
if constexpr (std::is_same_v<T, QAbstractSocket>) {
|
||||||
return s->peerName();
|
return s->peerName();
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
} else if constexpr (std::is_same_v<T, QLocalSocket>) {
|
||||||
return s->serverName();
|
return s->serverName();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
};
|
};
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
#include <QtNetwork/qtcpserver.h>
|
#include <QtNetwork/qtcpserver.h>
|
||||||
#include <QtNetwork/qtcpsocket.h>
|
#include <QtNetwork/qtcpsocket.h>
|
||||||
#include <QtNetwork/qlocalsocket.h>
|
|
||||||
#if QT_CONFIG(ssl)
|
#if QT_CONFIG(ssl)
|
||||||
# include <QtNetwork/qsslsocket.h>
|
# include <QtNetwork/qsslsocket.h>
|
||||||
#endif
|
#endif
|
||||||
#if QT_CONFIG(localserver)
|
#if QT_CONFIG(localserver)
|
||||||
# include <QtNetwork/qlocalserver.h>
|
# include <QtNetwork/qlocalserver.h>
|
||||||
|
# include <QtNetwork/qlocalsocket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
@ -62,8 +62,10 @@ public:
|
|||||||
for (auto [socket, _] : copy.asKeyValueRange()) {
|
for (auto [socket, _] : copy.asKeyValueRange()) {
|
||||||
if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket))
|
if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket))
|
||||||
tcpSocket->disconnectFromHost();
|
tcpSocket->disconnectFromHost();
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket))
|
else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket))
|
||||||
localSocket->disconnectFromServer();
|
localSocket->disconnectFromServer();
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
Q_UNREACHABLE_RETURN();
|
Q_UNREACHABLE_RETURN();
|
||||||
socket->deleteLater();
|
socket->deleteLater();
|
||||||
@ -136,11 +138,13 @@ private:
|
|||||||
|
|
||||||
if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket)) {
|
if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket)) {
|
||||||
connect(tcpSocket, &QAbstractSocket::errorOccurred, this, &MiniHttpServerV2::slotError);
|
connect(tcpSocket, &QAbstractSocket::errorOccurred, this, &MiniHttpServerV2::slotError);
|
||||||
|
#if QT_CONFIG(localserver)
|
||||||
} else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket)) {
|
} else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket)) {
|
||||||
connect(localSocket, &QLocalSocket::errorOccurred, this,
|
connect(localSocket, &QLocalSocket::errorOccurred, this,
|
||||||
[this](QLocalSocket::LocalSocketError error) {
|
[this](QLocalSocket::LocalSocketError error) {
|
||||||
slotError(QAbstractSocket::SocketError(error));
|
slotError(QAbstractSocket::SocketError(error));
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
Q_UNREACHABLE_RETURN();
|
Q_UNREACHABLE_RETURN();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user