service/tray: delete image pixmaps created with new[] using delete[]

This commit is contained in:
outfoxxed 2024-09-15 13:50:00 -07:00
parent 01f2be057e
commit bdc9fe958b
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -14,7 +14,7 @@ QImage DBusSniIconPixmap::createImage() const {
// fix byte order if on a little endian machine
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
auto* newbuf = new quint32[this->data.size()];
const auto* oldbuf = reinterpret_cast<const quint32*>(this->data.data()); // NOLINT
const auto* oldbuf = reinterpret_cast<const quint32*>(this->data.constData()); // NOLINT
for (uint i = 0; i < this->data.size() / sizeof(quint32); ++i) {
newbuf[i] = qFromBigEndian(oldbuf[i]); // NOLINT
@ -25,12 +25,12 @@ QImage DBusSniIconPixmap::createImage() const {
this->width,
this->height,
QImage::Format_ARGB32,
[](void* ptr) { delete reinterpret_cast<quint32*>(ptr); }, // NOLINT
[](void* ptr) { delete[] reinterpret_cast<quint32*>(ptr); }, // NOLINT
newbuf
);
} else {
return QImage(
reinterpret_cast<const uchar*>(this->data.data()), // NOLINT
reinterpret_cast<const uchar*>(this->data.constData()), // NOLINT
this->width,
this->height,
QImage::Format_ARGB32