update deprecated methods in qt5.14 and protobuf 3.4 (#3906)

This commit is contained in:
ebbit1q 2020-03-17 01:41:41 +01:00 committed by GitHub
parent 361833e023
commit a80c756dcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 37 deletions

View file

@ -261,7 +261,11 @@ void IslInterface::catchSocketError(QAbstractSocket::SocketError socketError)
void IslInterface::transmitMessage(const IslMessage &item)
{
QByteArray buf;
#if GOOGLE_PROTOBUF_VERSION > 3001000
unsigned int size = item.ByteSizeLong();
#else
unsigned int size = item.ByteSize();
#endif
buf.resize(size + 4);
item.SerializeToArray(buf.data() + 4, size);
buf.data()[3] = (unsigned char)size;

View file

@ -804,7 +804,11 @@ void Servatrice_DatabaseInterface::storeGameInformation(const QString &roomName,
QVariantList replayIds, replayGameIds, replayDurations, replayBlobs;
for (int i = 0; i < replayList.size(); ++i) {
QByteArray blob;
#if GOOGLE_PROTOBUF_VERSION > 3001000
const unsigned int size = replayList[i]->ByteSizeLong();
#else
const unsigned int size = replayList[i]->ByteSize();
#endif
blob.resize(size);
replayList[i]->SerializeToArray(blob.data(), size);
@ -1376,4 +1380,4 @@ void Servatrice_DatabaseInterface::addAuditRecord(const QString &user,
query->bindValue(":details", details);
execSqlQuery(query);
}
}

View file

@ -1553,7 +1553,11 @@ void TcpServerSocketInterface::flushOutputQueue()
locker.unlock();
QByteArray buf;
#if GOOGLE_PROTOBUF_VERSION > 3001000
unsigned int size = item.ByteSizeLong();
#else
unsigned int size = item.ByteSize();
#endif
buf.resize(size + 4);
item.SerializeToArray(buf.data() + 4, size);
buf.data()[3] = (unsigned char)size;
@ -1747,7 +1751,11 @@ void WebsocketServerSocketInterface::flushOutputQueue()
locker.unlock();
QByteArray buf;
#if GOOGLE_PROTOBUF_VERSION > 3001000
unsigned int size = item.ByteSizeLong();
#else
unsigned int size = item.ByteSize();
#endif
buf.resize(size);
item.SerializeToArray(buf.data(), size);
// In case socket->write() calls catchSocketError(), the mutex must not be locked during this call.