Commit 6d06d47a authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Do not use qMemSet and qMemCopy.



They are deprecated in Qt 5. Call std::memset and std::memcpy instead.

Change-Id: I53c22283208b4d6fdfcba870c3b141f3c02001bd
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 0b28569e
......@@ -33,6 +33,8 @@
#include <QSharedMemory>
#include <QCache>
#include <cstring>
namespace QmlDesigner {
static QCache<qint32, QSharedMemory> globalSharedMemoryCache(10000);
......@@ -104,7 +106,7 @@ QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
QSharedMemory *sharedMemory = createSharedMemory(keyCounter, outDataStreamByteArray.size());
if (sharedMemory) {
qMemCopy(sharedMemory->data(), outDataStreamByteArray.constData(), sharedMemory->size());
std::memcpy(sharedMemory->data(), outDataStreamByteArray.constData(), sharedMemory->size());
out << command.keyNumber();
return out;
}
......
......@@ -33,6 +33,8 @@
#include <QSharedMemory>
#include <QCache>
#include <cstring>
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
......@@ -125,8 +127,8 @@ static void writeSharedMemory(QSharedMemory *sharedMemory, const QImage &image)
headerData[3] = image.size().height();
headerData[4] = image.format();
qMemCopy(sharedMemory->data(), headerData, 20);
qMemCopy(reinterpret_cast<char*>(sharedMemory->data()) + 20, image.constBits(), image.byteCount());
std::memcpy(sharedMemory->data(), headerData, 20);
std::memcpy(reinterpret_cast<char*>(sharedMemory->data()) + 20, image.constBits(), image.byteCount());
sharedMemory->unlock();
}
......@@ -177,7 +179,7 @@ static void readSharedMemory(qint32 key, ImageContainer &container)
{
sharedMemory.lock();
qint32 headerData[5];
qMemCopy(headerData, sharedMemory.constData(), 20);
std::memcpy(headerData, sharedMemory.constData(), 20);
qint32 byteCount = headerData[0];
// qint32 bytesPerLine = headerData[1];
......@@ -187,7 +189,7 @@ static void readSharedMemory(qint32 key, ImageContainer &container)
QImage image = QImage(imageWidth, imageHeight, QImage::Format(imageFormat));
qMemCopy(image.bits(), reinterpret_cast<const qint32*>(sharedMemory.constData()) + 5, byteCount);
std::memcpy(image.bits(), reinterpret_cast<const qint32*>(sharedMemory.constData()) + 5, byteCount);
container.setImage(image);
......
......@@ -57,6 +57,8 @@
#include <utils/networkaccessmanager.h>
#include <cstring>
using namespace Find;
using namespace Help;
using namespace Help::Internal;
......@@ -147,7 +149,7 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
{
qint64 len = qMin(qint64(data.length()), maxlen);
if (len) {
qMemCopy(buffer, data.constData(), len);
std::memcpy(buffer, data.constData(), len);
data.remove(0, len);
}
return len;
......
......@@ -39,6 +39,8 @@
#include <QFile>
#include <QFileInfo>
#include <cstring>
using namespace ProjectExplorer;
namespace RemoteLinux {
......@@ -224,7 +226,7 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn
const QString &remoteFilePath)
{
TarFileHeader header;
qMemSet(&header, '\0', sizeof header);
std::memset(&header, '\0', sizeof header);
const QByteArray &filePath = remoteFilePath.toUtf8();
const int maxFilePathLength = sizeof header.fileNamePrefix + sizeof header.fileName;
if (filePath.count() > maxFilePathLength) {
......@@ -235,9 +237,9 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn
const int fileNameBytesToWrite = qMin<int>(filePath.length(), sizeof header.fileName);
const int fileNameOffset = filePath.length() - fileNameBytesToWrite;
qMemCopy(&header.fileName, filePath.data() + fileNameOffset, fileNameBytesToWrite);
std::memcpy(&header.fileName, filePath.data() + fileNameOffset, fileNameBytesToWrite);
if (fileNameOffset > 0)
qMemCopy(&header.fileNamePrefix, filePath.data(), fileNameOffset);
std::memcpy(&header.fileNamePrefix, filePath.data(), fileNameOffset);
int permissions = (0400 * fileInfo.permission(QFile::ReadOwner))
| (0200 * fileInfo.permission(QFile::WriteOwner))
| (0100 * fileInfo.permission(QFile::ExeOwner))
......@@ -249,34 +251,34 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn
| (01 * fileInfo.permission(QFile::ExeOther));
const QByteArray permissionString = QString("%1").arg(permissions,
sizeof header.fileMode - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.fileMode, permissionString.data(), permissionString.length());
std::memcpy(&header.fileMode, permissionString.data(), permissionString.length());
const QByteArray uidString = QString("%1").arg(fileInfo.ownerId(),
sizeof header.uid - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.uid, uidString.data(), uidString.length());
std::memcpy(&header.uid, uidString.data(), uidString.length());
const QByteArray gidString = QString("%1").arg(fileInfo.groupId(),
sizeof header.gid - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.gid, gidString.data(), gidString.length());
std::memcpy(&header.gid, gidString.data(), gidString.length());
const QByteArray sizeString = QString("%1").arg(fileInfo.size(),
sizeof header.length - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.length, sizeString.data(), sizeString.length());
std::memcpy(&header.length, sizeString.data(), sizeString.length());
const QByteArray mtimeString = QString("%1").arg(fileInfo.lastModified().toTime_t(),
sizeof header.mtime - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.mtime, mtimeString.data(), mtimeString.length());
std::memcpy(&header.mtime, mtimeString.data(), mtimeString.length());
if (fileInfo.isDir())
header.typeflag = '5';
qMemCopy(&header.magic, "ustar", sizeof "ustar");
qMemCopy(&header.version, "00", 2);
std::memcpy(&header.magic, "ustar", sizeof "ustar");
std::memcpy(&header.version, "00", 2);
const QByteArray &owner = fileInfo.owner().toUtf8();
qMemCopy(&header.uname, owner.data(), qMin<int>(owner.length(), sizeof header.uname - 1));
std::memcpy(&header.uname, owner.data(), qMin<int>(owner.length(), sizeof header.uname - 1));
const QByteArray &group = fileInfo.group().toUtf8();
qMemCopy(&header.gname, group.data(), qMin<int>(group.length(), sizeof header.gname - 1));
qMemSet(&header.chksum, ' ', sizeof header.chksum);
std::memcpy(&header.gname, group.data(), qMin<int>(group.length(), sizeof header.gname - 1));
std::memset(&header.chksum, ' ', sizeof header.chksum);
quint64 checksum = 0;
for (size_t i = 0; i < sizeof header; ++i)
checksum += reinterpret_cast<char *>(&header)[i];
const QByteArray checksumString = QString("%1").arg(checksum,
sizeof header.chksum - 1, 8, QLatin1Char('0')).toAscii();
qMemCopy(&header.chksum, checksumString.data(), checksumString.length());
std::memcpy(&header.chksum, checksumString.data(), checksumString.length());
header.chksum[sizeof header.chksum-1] = 0;
if (!tarFile.write(reinterpret_cast<char *>(&header), sizeof header)) {
raiseError(tr("Error writing tar file '%1': %2")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment