Skip to content

Commit 529d1e7

Browse files
fix compilation error on ubuntu20
1 parent ed4ffd8 commit 529d1e7

10 files changed

+24
-27
lines changed

src/tabstractwebsocket.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ bool TAbstractWebSocket::searchEndpoint(const THttpRequestHeader &header)
167167

168168
int TAbstractWebSocket::parse(QByteArray &recvData)
169169
{
170-
tSystemDebug("parse enter data len:{} sid:{}", (int64_t)recvData.length(), socketDescriptor());
170+
tSystemDebug("parse enter data len:{} sid:{}", (qint64)recvData.length(), socketDescriptor());
171171
if (websocketFrames().isEmpty()) {
172172
websocketFrames().append(TWebSocketFrame());
173173
} else {
@@ -269,7 +269,7 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
269269
case TWebSocketFrame::HeaderParsed: // fall through
270270
case TWebSocketFrame::MoreData: {
271271
tSystemDebug("WebSocket reading payload: available length:{}", dev->bytesAvailable());
272-
tSystemDebug("WebSocket parsing length to read:{} current buf len:{}", pfrm->payloadLength(), (int64_t)pfrm->payload().size());
272+
tSystemDebug("WebSocket parsing length to read:{} current buf len:{}", pfrm->payloadLength(), (qint64)pfrm->payload().size());
273273
uint64_t size = std::min((uint64_t)(pfrm->payloadLength() - pfrm->payload().size()), (uint64_t)dev->bytesAvailable());
274274
if (Q_UNLIKELY(size == 0)) {
275275
Q_ASSERT(0);
@@ -293,14 +293,14 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
293293
}
294294
}
295295
pfrm->payload().resize(pfrm->payload().size() + size);
296-
tSystemDebug("WebSocket payload curent buf len: {}", (int64_t)pfrm->payload().length());
296+
tSystemDebug("WebSocket payload curent buf len: {}", (qint64)pfrm->payload().length());
297297

298298
if ((uint64_t)pfrm->payload().size() == pfrm->payloadLength()) {
299299
pfrm->setState(TWebSocketFrame::Completed);
300-
tSystemDebug("Parse Completed payload len: {}", (int64_t)pfrm->payload().size());
300+
tSystemDebug("Parse Completed payload len: {}", (qint64)pfrm->payload().size());
301301
} else {
302302
pfrm->setState(TWebSocketFrame::MoreData);
303-
tSystemDebug("Parse MoreData payload len: {}", (int64_t)pfrm->payload().size());
303+
tSystemDebug("Parse MoreData payload len: {}", (qint64)pfrm->payload().size());
304304
}
305305
break;
306306
}

src/tactioncontext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ int64_t TActionContext::writeResponse(THttpResponseHeader &header, QIODevice *bo
459459
{
460460

461461
header.setContentLength(length);
462-
tSystemDebug("content-length: {}", (int64_t)header.contentLength());
462+
tSystemDebug("content-length: {}", (qint64)header.contentLength());
463463
header.setRawHeader(QByteArrayLiteral("Server"), QByteArrayLiteral("TreeFrog server"));
464464
header.setCurrentDate();
465465

src/tactionthread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void TActionThread::run()
112112
try {
113113
for (;;) {
114114
QList<THttpRequest> requests = readRequest(_httpSocket);
115-
tSystemDebug("HTTP request count: {}", (int64_t)requests.count());
115+
tSystemDebug("HTTP request count: {}", (qint64)requests.count());
116116

117117
if (requests.isEmpty()) {
118118
break;

src/tepollwebsocket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bool TEpollWebSocket::isBinaryRequest() const
7777

7878
void TEpollWebSocket::sendTextForPublish(const QString &text, const QObject *except)
7979
{
80-
tSystemDebug("sendText text len:{} (pid:{})", (int64_t)text.length(), (int)QCoreApplication::applicationPid());
80+
tSystemDebug("sendText text len:{} (pid:{})", (qint64)text.length(), (int)QCoreApplication::applicationPid());
8181
if (except != this) {
8282
TAbstractWebSocket::sendText(text);
8383
}
@@ -86,7 +86,7 @@ void TEpollWebSocket::sendTextForPublish(const QString &text, const QObject *exc
8686

8787
void TEpollWebSocket::sendBinaryForPublish(const QByteArray &binary, const QObject *except)
8888
{
89-
tSystemDebug("sendBinary binary len:{} (pid:{})", (int64_t)binary.length(), (int)QCoreApplication::applicationPid());
89+
tSystemDebug("sendBinary binary len:{} (pid:{})", (qint64)binary.length(), (int)QCoreApplication::applicationPid());
9090
if (except != this) {
9191
TAbstractWebSocket::sendBinary(binary);
9292
}
@@ -95,7 +95,7 @@ void TEpollWebSocket::sendBinaryForPublish(const QByteArray &binary, const QObje
9595

9696
void TEpollWebSocket::sendPong(const QByteArray &data)
9797
{
98-
tSystemDebug("sendPong data len:{} (pid:{})", (int64_t)data.length(), (int)QCoreApplication::applicationPid());
98+
tSystemDebug("sendPong data len:{} (pid:{})", (qint64)data.length(), (int)QCoreApplication::applicationPid());
9999
TAbstractWebSocket::sendPong(data);
100100
}
101101

src/tfnamespace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ enum class SocketState : int {
254254

255255
constexpr auto KeepEmptyParts = Qt::KeepEmptyParts;
256256
constexpr auto SkipEmptyParts = Qt::SkipEmptyParts;
257+
constexpr auto ReadOnly = QIODeviceBase::ReadOnly;
258+
constexpr auto WriteOnly = QIODeviceBase::WriteOnly;
257259
} // namespace Tf
258260

259261

src/tglobal.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ constexpr auto TF_SRC_REVISION = 2956;
66
#include <QMetaType>
77
#include <QIODevice>
88
#include <QtGlobal>
9+
#include <version>
910

1011

12+
#if defined(__cpp_lib_format) || __has_include(<format>) // std::format
13+
#define TF_HAVE_STD_FORMAT
14+
#endif
15+
1116
#define T_DEFINE_CONTROLLER(TYPE) T_DEFINE_TYPE(TYPE)
1217
#define T_DEFINE_VIEW(TYPE) T_DEFINE_TYPE(TYPE)
1318
#define T_DEFINE_TYPE(TYPE) \
@@ -168,16 +173,6 @@ constexpr auto TF_SRC_REVISION = 2956;
168173
#define tTrace TDebug(Tf::TraceLevel).trace
169174

170175

171-
namespace Tf {
172-
constexpr auto ReadOnly = QIODeviceBase::ReadOnly;
173-
constexpr auto WriteOnly = QIODeviceBase::WriteOnly;
174-
}
175-
176-
177-
#if (!defined(Q_OS_WIN) && defined(__cpp_lib_format)) || (defined(_MSC_VER) && _MSC_VER >= 1930) // std::format
178-
#define TF_HAVE_STD_FORMAT
179-
#endif
180-
181176
#include "tfexception.h"
182177
#include "tfnamespace.h"
183178
#include "tdeclexport.h"

src/tpublisher.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void TPublisher::unsubscribeFromAll(TAbstractWebSocket *socket)
168168
}
169169
}
170170

171-
tSystemDebug("total topics: {}", (int64_t)pubobj.count());
171+
tSystemDebug("total topics: {}", (qint64)pubobj.count());
172172
}
173173

174174

@@ -282,6 +282,6 @@ void TPublisher::release(const QString &topic)
282282
Pub *pub = pubobj.take(topic);
283283
if (pub) {
284284
delete pub;
285-
tSystemDebug("release topic: {} (total topics:{})", qUtf8Printable(topic), (int64_t)pubobj.count());
285+
tSystemDebug("release topic: {} (total topics:{})", qUtf8Printable(topic), (qint64)pubobj.count());
286286
}
287287
}

src/tsystembus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void TSystemBus::readBus()
112112
void TSystemBus::writeBus()
113113
{
114114
QMutexLocker locker(&mutexWrite);
115-
tSystemDebug("TSystemBus::writeBus len:{}", (int64_t)sendBuffer.length());
115+
tSystemDebug("TSystemBus::writeBus len:{}", (qint64)sendBuffer.length());
116116

117117
for (;;) {
118118
int len = busSocket->write(sendBuffer.data(), sendBuffer.length());

src/tthreadapplicationserver_qt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void TThreadApplicationServer::stop()
8383

8484
void TThreadApplicationServer::incomingConnection(qintptr socketDescriptor)
8585
{
86-
tSystemDebug("incomingConnection sd:{} thread count:{} max:{}", (int64_t)socketDescriptor, TActionThread::threadCount(), maxThreads);
86+
tSystemDebug("incomingConnection sd:{} thread count:{} max:{}", (qint64)socketDescriptor, TActionThread::threadCount(), maxThreads);
8787
TActionThread *thread;
8888
while (!threadPoolPtr()->pop(thread)) {
8989
std::this_thread::yield();

src/twebsocket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void TWebSocket::close()
5656

5757
void TWebSocket::sendTextForPublish(const QString &text, const QObject *except)
5858
{
59-
tSystemDebug("sendText text len:{} (pid:{})", (int64_t)text.length(), (int)QCoreApplication::applicationPid());
59+
tSystemDebug("sendText text len:{} (pid:{})", (qint64)text.length(), (int)QCoreApplication::applicationPid());
6060
if (except != this) {
6161
TAbstractWebSocket::sendText(text);
6262
}
@@ -65,7 +65,7 @@ void TWebSocket::sendTextForPublish(const QString &text, const QObject *except)
6565

6666
void TWebSocket::sendBinaryForPublish(const QByteArray &binary, const QObject *except)
6767
{
68-
tSystemDebug("sendBinary binary len:{} (pid:{})", (int64_t)binary.length(), (int)QCoreApplication::applicationPid());
68+
tSystemDebug("sendBinary binary len:{} (pid:{})", (qint64)binary.length(), (int)QCoreApplication::applicationPid());
6969
if (except != this) {
7070
TAbstractWebSocket::sendBinary(binary);
7171
}
@@ -74,7 +74,7 @@ void TWebSocket::sendBinaryForPublish(const QByteArray &binary, const QObject *e
7474

7575
void TWebSocket::sendPong(const QByteArray &data)
7676
{
77-
tSystemDebug("sendPong data len:{} (pid:{})", (int64_t)data.length(), (int)QCoreApplication::applicationPid());
77+
tSystemDebug("sendPong data len:{} (pid:{})", (qint64)data.length(), (int)QCoreApplication::applicationPid());
7878
TAbstractWebSocket::sendPong(data);
7979
}
8080

0 commit comments

Comments
 (0)