[Qt] Fix deprecation warnings in Qt 5.10

This commit is contained in:
Bruno de Oliveira Abinader
2017-11-13 13:36:55 +02:00
committed by Thiago Marcos P. Santos
parent 92608f5885
commit 10a9b25928
2 changed files with 10 additions and 0 deletions

View File

@@ -111,8 +111,13 @@ std::unique_ptr<mbgl::style::Image> toStyleImage(const QString &id, const QImage
.rgbSwapped()
.convertToFormat(QImage::Format_ARGB32_Premultiplied);
#if QT_VERSION >= 0x051000
auto img = std::make_unique<uint8_t[]>(swapped.sizeInBytes());
memcpy(img.get(), swapped.constBits(), swapped.sizeInBytes());
#else
auto img = std::make_unique<uint8_t[]>(swapped.byteCount());
memcpy(img.get(), swapped.constBits(), swapped.byteCount());
#endif
return std::make_unique<mbgl::style::Image>(
id.toStdString(),

View File

@@ -54,8 +54,13 @@ PremultipliedImage decodeImage(const std::string& string) {
throw std::runtime_error("Unsupported image type");
}
#if QT_VERSION >= 0x051000
auto img = std::make_unique<uint8_t[]>(image.sizeInBytes());
memcpy(img.get(), image.constBits(), image.sizeInBytes());
#else
auto img = std::make_unique<uint8_t[]>(image.byteCount());
memcpy(img.get(), image.constBits(), image.byteCount());
#endif
return { { static_cast<uint32_t>(image.width()), static_cast<uint32_t>(image.height()) },
std::move(img) };