From 72ede666d4840d52928ca45042f8869e4a08b4a6 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Mon, 15 Jun 2020 17:59:02 +0200 Subject: [PATCH] Replace use of C style casts --- .../singleapplication/singleapplication_p.cpp | 6 ++-- .../singlecoreapplication_p.cpp | 6 ++-- 3rdparty/taglib/asf/asfattribute.cpp | 4 +-- 3rdparty/taglib/asf/asffile.cpp | 6 ++-- 3rdparty/taglib/asf/asfpicture.cpp | 4 +-- 3rdparty/taglib/dsdiff/dsdifffile.cpp | 10 ++---- 3rdparty/taglib/it/itfile.cpp | 16 +++++----- 3rdparty/taglib/mod/modfilebase.cpp | 2 +- 3rdparty/taglib/mp4/mp4tag.cpp | 6 ++-- 3rdparty/taglib/mpc/mpcproperties.cpp | 8 ++--- .../id3v2/frames/attachedpictureframe.cpp | 4 +-- .../mpeg/id3v2/frames/popularimeterframe.cpp | 2 +- .../mpeg/id3v2/frames/relativevolumeframe.cpp | 2 +- .../id3v2/frames/tableofcontentsframe.cpp | 2 +- 3rdparty/taglib/s3m/s3mfile.cpp | 8 ++--- 3rdparty/taglib/toolkit/tbytevector.cpp | 6 ++-- 3rdparty/taglib/xm/xmfile.cpp | 4 +-- ext/gstmoodbar/gstfastspectrum.cpp | 8 ++--- ext/libstrawberry-common/core/logging.cpp | 4 +-- ext/libstrawberry-tagreader/tagreader.cpp | 4 +-- src/analyzer/analyzerbase.cpp | 8 ++--- src/analyzer/blockanalyzer.cpp | 4 +-- src/context/contextview.cpp | 2 +- src/core/mainwindow.cpp | 4 +-- src/core/utilities.cpp | 2 +- .../albumcoverchoicecontroller.cpp | 4 +-- src/device/cddasongloader.cpp | 4 +-- src/device/giolister.cpp | 8 ++--- src/device/mtpconnection.cpp | 2 +- src/engine/gstengine.cpp | 4 +-- src/engine/gstenginepipeline.cpp | 10 +++--- src/engine/xineengine.cpp | 32 +++++++++---------- src/playlist/playlist.cpp | 10 +++--- src/settings/collectionsettingspage.cpp | 4 +-- src/widgets/fancytabwidget.cpp | 6 ++-- 35 files changed, 105 insertions(+), 111 deletions(-) diff --git a/3rdparty/singleapplication/singleapplication_p.cpp b/3rdparty/singleapplication/singleapplication_p.cpp index c80ea37d8..f0113f7b1 100644 --- a/3rdparty/singleapplication/singleapplication_p.cpp +++ b/3rdparty/singleapplication/singleapplication_p.cpp @@ -306,7 +306,7 @@ void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) { return; } - if (sock->bytesAvailable() < (qint64) sizeof(quint64)) { + if (sock->bytesAvailable() < static_cast(sizeof(quint64))) { return; } @@ -321,7 +321,7 @@ void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) { info.stage = StageBody; info.msgLen = msgLen; - if (sock->bytesAvailable() >= (qint64) msgLen) { + if (sock->bytesAvailable() >= static_cast(msgLen)) { readInitMessageBody(sock); } @@ -336,7 +336,7 @@ void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) { } ConnectionInfo &info = connectionMap[sock]; - if (sock->bytesAvailable() < (qint64)info.msgLen) { + if (sock->bytesAvailable() < static_cast(info.msgLen)) { return; } diff --git a/3rdparty/singleapplication/singlecoreapplication_p.cpp b/3rdparty/singleapplication/singlecoreapplication_p.cpp index 0d560cfe2..c15ab15e1 100644 --- a/3rdparty/singleapplication/singlecoreapplication_p.cpp +++ b/3rdparty/singleapplication/singlecoreapplication_p.cpp @@ -306,7 +306,7 @@ void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) { return; } - if (sock->bytesAvailable() < (qint64)sizeof(quint64)) { + if (sock->bytesAvailable() < static_cast(sizeof(quint64))) { return; } @@ -321,7 +321,7 @@ void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) { info.stage = StageBody; info.msgLen = msgLen; - if (sock->bytesAvailable() >= (qint64) msgLen) { + if (sock->bytesAvailable() >= static_cast(msgLen)) { readInitMessageBody(sock); } @@ -336,7 +336,7 @@ void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) { } ConnectionInfo &info = connectionMap[sock]; - if (sock->bytesAvailable() < (qint64)info.msgLen) { + if (sock->bytesAvailable() < static_cast(info.msgLen)) { return; } diff --git a/3rdparty/taglib/asf/asfattribute.cpp b/3rdparty/taglib/asf/asfattribute.cpp index 337571f76..18a1522f8 100644 --- a/3rdparty/taglib/asf/asfattribute.cpp +++ b/3rdparty/taglib/asf/asfattribute.cpp @@ -282,7 +282,7 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const { if (kind == 0) { data = renderString(name, true) + - ByteVector::fromShort((int)d->type, false) + + ByteVector::fromShort(static_cast(d->type), false) + ByteVector::fromShort(data.size(), false) + data; } @@ -291,7 +291,7 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const { data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) + ByteVector::fromShort(d->stream, false) + ByteVector::fromShort(nameData.size(), false) + - ByteVector::fromShort((int)d->type, false) + + ByteVector::fromShort(static_cast(d->type), false) + ByteVector::fromUInt(data.size(), false) + nameData + data; diff --git a/3rdparty/taglib/asf/asffile.cpp b/3rdparty/taglib/asf/asffile.cpp index 112e731cf..a07165fdb 100644 --- a/3rdparty/taglib/asf/asffile.cpp +++ b/3rdparty/taglib/asf/asffile.cpp @@ -179,7 +179,7 @@ class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::B void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) { data.clear(); - if (size > 24 && size <= (unsigned int)(file->length())) + if (size > 24 && size <= static_cast(file->length())) data = file->readBlock(size - 24); else data = ByteVector(); @@ -384,7 +384,7 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig else { obj = new UnknownObject(guid); } - obj->parse(file, (unsigned int)size); + obj->parse(file, static_cast(size)); objects.append(obj); dataPos += size; } @@ -632,7 +632,7 @@ void ASF::File::read() { setValid(false); break; } - long size = (long)readQWORD(this, &ok); + long size = static_cast(readQWORD(this, &ok)); if (!ok) { setValid(false); break; diff --git a/3rdparty/taglib/asf/asfpicture.cpp b/3rdparty/taglib/asf/asfpicture.cpp index 4464efd58..9542f9635 100644 --- a/3rdparty/taglib/asf/asfpicture.cpp +++ b/3rdparty/taglib/asf/asfpicture.cpp @@ -117,7 +117,7 @@ ByteVector ASF::Picture::render() const { if (!isValid()) return ByteVector(); - return ByteVector((char)d->type) + + return ByteVector(static_cast(d->type)) + ByteVector::fromUInt(d->picture.size(), false) + renderString(d->mimeType) + renderString(d->description) + @@ -131,7 +131,7 @@ void ASF::Picture::parse(const ByteVector &bytes) { if (bytes.size() < 9) return; int pos = 0; - d->type = (Type)bytes[0]; + d->type = static_cast(bytes[0]); ++pos; const unsigned int dataLen = bytes.toUInt(pos, false); pos += 4; diff --git a/3rdparty/taglib/dsdiff/dsdifffile.cpp b/3rdparty/taglib/dsdiff/dsdifffile.cpp index a58aacb11..2c39447a1 100644 --- a/3rdparty/taglib/dsdiff/dsdifffile.cpp +++ b/3rdparty/taglib/dsdiff/dsdifffile.cpp @@ -855,9 +855,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty if (lengthDSDSamplesTimeChannels == 0) { // DST compressed signal : need to compute length of DSD uncompressed frames if (dstFrameRate > 0) - lengthDSDSamplesTimeChannels = (unsigned long long)dstNumFrames * - (unsigned long long)sampleRate / - (unsigned long long)dstFrameRate; + lengthDSDSamplesTimeChannels = static_cast(dstNumFrames) * static_cast(sampleRate) / static_cast(dstFrameRate); else lengthDSDSamplesTimeChannels = 0; } @@ -870,11 +868,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty if (lengthDSDSamplesTimeChannels > 0) bitrate = (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000; - d->properties = new Properties(sampleRate, - channels, - lengthDSDSamplesTimeChannels, - bitrate, - propertiesStyle); + d->properties = new Properties(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle); } if (!ID3v2Tag()) { diff --git a/3rdparty/taglib/it/itfile.cpp b/3rdparty/taglib/it/itfile.cpp index b4ede3c8c..ce42014f8 100644 --- a/3rdparty/taglib/it/itfile.cpp +++ b/3rdparty/taglib/it/itfile.cpp @@ -101,7 +101,7 @@ bool IT::File::save() { // write comment as instrument and sample names: StringList lines = d->tag.comment().split("\n"); for (unsigned short i = 0; i < instrumentCount; ++i) { - seek(192L + length + ((long)i << 2)); + seek(192L + length + (static_cast(i) << 2)); unsigned long instrumentOffset = 0; if (!readU32L(instrumentOffset)) return false; @@ -116,14 +116,14 @@ bool IT::File::save() { } for (unsigned short i = 0; i < sampleCount; ++i) { - seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); + seek(192L + length + (static_cast(instrumentCount) << 2) + (static_cast(i) << 2)); unsigned long sampleOffset = 0; if (!readU32L(sampleOffset)) return false; seek(sampleOffset + 20); - if ((unsigned int)(i + instrumentCount) < lines.size()) + if (static_cast(i + instrumentCount) < lines.size()) writeString(lines[i + instrumentCount], 25); else writeString(String(), 25); @@ -140,7 +140,7 @@ bool IT::File::save() { // terminating NUL but it does not hurt to add one: if (message.size() > 7999) message.resize(7999); - message.append((char)0); + message.append(static_cast(0)); unsigned short special = 0; unsigned short messageLength = 0; @@ -225,7 +225,7 @@ void IT::File::read(bool) { seek(messageOffset); ByteVector messageBytes = readBlock(messageLength); READ_ASSERT(messageBytes.size() == messageLength); - int index = messageBytes.find((char)0); + int index = messageBytes.find(static_cast(0)); if (index > -1) messageBytes.resize(index, 0); messageBytes.replace('\r', '\n'); @@ -244,7 +244,7 @@ void IT::File::read(bool) { // But this always gives 64 channels for all my files anyway. // Strangely VLC does report other values. I wonder how VLC // gets it's values. - if ((unsigned char)pannings[i] < 128 && volumes[i] > 0) + if (static_cast(pannings[i]) < 128 && volumes[i] > 0) ++channels; } d->properties.setChannels(channels); @@ -266,7 +266,7 @@ void IT::File::read(bool) { // e.g. VLC seems to interpret a nil as a space. I // don't know what is the proper behaviour. for (unsigned short i = 0; i < instrumentCount; ++i) { - seek(192L + length + ((long)i << 2)); + seek(192L + length + (static_cast(i) << 2)); READ_U32L_AS(instrumentOffset); seek(instrumentOffset); @@ -282,7 +282,7 @@ void IT::File::read(bool) { } for (unsigned short i = 0; i < sampleCount; ++i) { - seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); + seek(192L + length + (static_cast(instrumentCount) << 2) + (static_cast(i) << 2)); READ_U32L_AS(sampleOffset); seek(sampleOffset); diff --git a/3rdparty/taglib/mod/modfilebase.cpp b/3rdparty/taglib/mod/modfilebase.cpp index 06de3183a..a340b4f27 100644 --- a/3rdparty/taglib/mod/modfilebase.cpp +++ b/3rdparty/taglib/mod/modfilebase.cpp @@ -44,7 +44,7 @@ bool Mod::FileBase::readString(String &s, unsigned long size) { ByteVector data(readBlock(size)); if (data.size() < size) return false; - int index = data.find((char)0); + int index = data.find(static_cast(0)); if (index > -1) { data.resize(index); } diff --git a/3rdparty/taglib/mp4/mp4tag.cpp b/3rdparty/taglib/mp4/mp4tag.cpp index 89a2c2365..81ea1cbdf 100644 --- a/3rdparty/taglib/mp4/mp4tag.cpp +++ b/3rdparty/taglib/mp4/mp4tag.cpp @@ -78,7 +78,7 @@ MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : d(new addItem(atom->name, StringList(String(val.data, String::UTF8))); } else { - addItem(atom->name, (int)(val.data.toShort())); + addItem(atom->name, static_cast((val.data.toShort()))); } } } @@ -169,7 +169,7 @@ void MP4::Tag::parseInt(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); if (!data.isEmpty()) { - addItem(atom->name, (int)data[0].toShort()); + addItem(atom->name, static_cast(data[0].toShort())); } } @@ -205,7 +205,7 @@ void MP4::Tag::parseGnre(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); if (!data.isEmpty()) { - int idx = (int)data[0].toShort(); + int idx = static_cast(data[0].toShort()); if (idx > 0) { addItem("\251gen", StringList(ID3v1::genre(idx - 1))); } diff --git a/3rdparty/taglib/mpc/mpcproperties.cpp b/3rdparty/taglib/mpc/mpcproperties.cpp index 9706a3090..d7f02a2c7 100644 --- a/3rdparty/taglib/mpc/mpcproperties.cpp +++ b/3rdparty/taglib/mpc/mpcproperties.cpp @@ -299,22 +299,22 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) { // convert gain info if (d->trackGain != 0) { - int tmp = (int)((64.82 - (short)d->trackGain / 100.) * 256. + .5); + int tmp = static_cast((64.82 - static_cast(d->trackGain) / 100.) * 256. + .5); if (tmp >= (1 << 16) || tmp < 0) tmp = 0; d->trackGain = tmp; } if (d->albumGain != 0) { - int tmp = (int)((64.82 - d->albumGain / 100.) * 256. + .5); + int tmp = static_cast((64.82 - d->albumGain / 100.) * 256. + .5); if (tmp >= (1 << 16) || tmp < 0) tmp = 0; d->albumGain = tmp; } if (d->trackPeak != 0) - d->trackPeak = (int)(log10((double)d->trackPeak) * 20 * 256 + .5); + d->trackPeak = static_cast(log10(static_cast(d->trackPeak)) * 20 * 256 + .5); if (d->albumPeak != 0) - d->albumPeak = (int)(log10((double)d->albumPeak) * 20 * 256 + .5); + d->albumPeak = static_cast(log10(static_cast(d->albumPeak)) * 20 * 256 + .5); bool trueGapless = (gapless >> 31) & 0x0001; if (trueGapless) { diff --git a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp index 762a38494..ee9cc453a 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp @@ -123,7 +123,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data) { return; } - d->type = (Strawberry_TagLib::TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++]; + d->type = static_cast(data[pos++]); d->description = readStringField(data, d->textEncoding, &pos); d->data = data.mid(pos); @@ -185,7 +185,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data) { d->mimeType = "image/" + fixedString; } - d->type = (Strawberry_TagLib::TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++]; + d->type = static_cast(data[pos++]); d->description = readStringField(data, d->textEncoding, &pos); d->data = data.mid(pos); diff --git a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp index 75125f96b..b7494b3a7 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp @@ -93,7 +93,7 @@ void PopularimeterFrame::parseFields(const ByteVector &data) { d->rating = 0; d->counter = 0; if (pos < size) { - d->rating = (unsigned char)(data[pos++]); + d->rating = static_cast(data[pos++]); if (pos < size) { d->counter = data.toUInt(static_cast(pos)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index e968286b4..9eb104f37 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -142,7 +142,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) { // Each channel is at least 4 bytes. - while (pos <= (int)data.size() - 4) { + while (pos <= static_cast(data.size()) - 4) { ChannelType type = ChannelType(data[pos]); pos += 1; diff --git a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index 5a7ce2972..6a3331b08 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -309,7 +309,7 @@ ByteVector TableOfContentsFrame::renderFields() const { if (d->isOrdered) flags += 1; data.append(flags); - data.append((char)(entryCount())); + data.append(static_cast(entryCount())); ByteVectorList::ConstIterator it = d->childElements.begin(); while (it != d->childElements.end()) { data.append(*it); diff --git a/3rdparty/taglib/s3m/s3mfile.cpp b/3rdparty/taglib/s3m/s3mfile.cpp index f7ff470ff..fc174be93 100644 --- a/3rdparty/taglib/s3m/s3mfile.cpp +++ b/3rdparty/taglib/s3m/s3mfile.cpp @@ -116,12 +116,12 @@ bool S3M::File::save() { StringList lines = d->tag.comment().split("\n"); // write comment as sample names: for (unsigned short i = 0; i < sampleCount; ++i) { - seek(96L + length + ((long)i << 1)); + seek(96L + length + (static_cast(i) << 1)); unsigned short instrumentOffset = 0; if (!readU16L(instrumentOffset)) return false; - seek(((long)instrumentOffset << 4) + 48); + seek((static_cast(instrumentOffset) << 4) + 48); if (i < lines.size()) writeString(lines[i], 27); @@ -202,10 +202,10 @@ void S3M::File::read(bool) { // instead samples (SCRS). StringList comment; for (unsigned short i = 0; i < sampleCount; ++i) { - seek(96L + length + ((long)i << 1)); + seek(96L + length + (static_cast(i) << 1)); READ_U16L_AS(sampleHeaderOffset); - seek((long)sampleHeaderOffset << 4); + seek(static_cast(sampleHeaderOffset) << 4); READ_BYTE_AS(sampleType); READ_STRING_AS(dosFileName, 13); diff --git a/3rdparty/taglib/toolkit/tbytevector.cpp b/3rdparty/taglib/toolkit/tbytevector.cpp index 6a007d15d..7af47ba49 100644 --- a/3rdparty/taglib/toolkit/tbytevector.cpp +++ b/3rdparty/taglib/toolkit/tbytevector.cpp @@ -848,8 +848,8 @@ ByteVector ByteVector::fromBase64(const ByteVector &input) { ByteVector output(len); - const unsigned char *src = (const unsigned char *)input.data(); - unsigned char *dst = (unsigned char *)output.data(); + const unsigned char *src = reinterpret_cast(input.data()); + unsigned char *dst = reinterpret_cast(output.data()); while (4 <= len) { @@ -899,7 +899,7 @@ ByteVector ByteVector::fromBase64(const ByteVector &input) { // Only return output if we processed all bytes if (len == 0) { - output.resize(static_cast(dst - (unsigned char *)output.data())); + output.resize(static_cast(dst - reinterpret_cast(output.data()))); return output; } return ByteVector(); diff --git a/3rdparty/taglib/xm/xmfile.cpp b/3rdparty/taglib/xm/xmfile.cpp index ea1d38118..11c7d7bab 100644 --- a/3rdparty/taglib/xm/xmfile.cpp +++ b/3rdparty/taglib/xm/xmfile.cpp @@ -115,7 +115,7 @@ class StringReader : public ValueReader { ByteVector data = file.readBlock(std::min(m_size, limit)); unsigned int count = data.size(); - int index = data.find((char)0); + int index = data.find(static_cast(0)); if (index > -1) { data.resize(index); } @@ -481,7 +481,7 @@ void XM::File::read(bool) { .u16L(bpmSpeed); unsigned int count = header.read(*this, headerSize - 4U); - unsigned int size = std::min(headerSize - 4U, (unsigned long)header.size()); + unsigned int size = std::min(headerSize - 4U, static_cast(header.size())); READ_ASSERT(count == size); diff --git a/ext/gstmoodbar/gstfastspectrum.cpp b/ext/gstmoodbar/gstfastspectrum.cpp index 743c49da9..6fddc921e 100644 --- a/ext/gstmoodbar/gstfastspectrum.cpp +++ b/ext/gstmoodbar/gstfastspectrum.cpp @@ -265,7 +265,7 @@ static void input_data_mixed_float(const guint8* _in, double* out, guint len, do Q_UNUSED(max_value); guint j, ip = 0; - gfloat *in = (gfloat *) _in; + const gfloat *in = reinterpret_cast(_in); for (j = 0; j < len; j++) { out[op] = in[ip++]; @@ -279,7 +279,7 @@ static void input_data_mixed_double (const guint8 * _in, double* out, guint len, Q_UNUSED(max_value); guint j, ip = 0; - gdouble *in = (gdouble *) _in; + const gdouble *in = reinterpret_cast(_in); for (j = 0; j < len; j++) { out[op] = in[ip++]; @@ -291,7 +291,7 @@ static void input_data_mixed_double (const guint8 * _in, double* out, guint len, static void input_data_mixed_int32_max (const guint8 * _in, double* out, guint len, double max_value, guint op, guint nfft) { guint j, ip = 0; - gint32 *in = (gint32 *) _in; + const gint32 *in = reinterpret_cast(_in); for (j = 0; j < len; j++) { out[op] = in[ip++] / max_value; @@ -323,7 +323,7 @@ static void input_data_mixed_int24_max (const guint8 * _in, double* out, guint l static void input_data_mixed_int16_max (const guint8 * _in, double * out, guint len, double max_value, guint op, guint nfft) { guint j, ip = 0; - gint16 *in = (gint16 *) _in; + const gint16 *in = reinterpret_cast(_in); for (j = 0; j < len; j++) { out[op] = in[ip++] / max_value; diff --git a/ext/libstrawberry-common/core/logging.cpp b/ext/libstrawberry-common/core/logging.cpp index 1daf01682..9ccbe0d28 100644 --- a/ext/libstrawberry-common/core/logging.cpp +++ b/ext/libstrawberry-common/core/logging.cpp @@ -196,10 +196,10 @@ void SetLevels(const QString &levels) { } if (class_name.isEmpty() || class_name == "*") { - sDefaultLevel = (Level) level; + sDefaultLevel = static_cast(level); } else { - sClassLevels->insert(class_name, (Level) level); + sClassLevels->insert(class_name, static_cast(level)); } } diff --git a/ext/libstrawberry-tagreader/tagreader.cpp b/ext/libstrawberry-tagreader/tagreader.cpp index 1fa878b23..afa971b8d 100644 --- a/ext/libstrawberry-tagreader/tagreader.cpp +++ b/ext/libstrawberry-tagreader/tagreader.cpp @@ -803,7 +803,7 @@ QByteArray TagReader::LoadEmbeddedArt(const QString &filename) const { TagLib::ID3v2::AttachedPictureFrame *pic = static_cast(apic_frames.front()); - return QByteArray((const char*) pic->picture().data(), pic->picture().size()); + return QByteArray(reinterpret_cast(pic->picture().data()), pic->picture().size()); } // MP4/AAC @@ -834,7 +834,7 @@ QByteArray TagReader::LoadEmbeddedAPEArt(const TagLib::APE::ItemListMap &map) co TagLib::ByteVector data = it->second.binaryData(); int pos = data.find('\0') + 1; - if ((pos > 0) && ((uint)pos < data.size())) { + if ((pos > 0) && (static_cast(pos) < data.size())) { ret = QByteArray(data.data() + pos, data.size() - pos); } } diff --git a/src/analyzer/analyzerbase.cpp b/src/analyzer/analyzerbase.cpp index a529e1c5c..e229a1524 100644 --- a/src/analyzer/analyzerbase.cpp +++ b/src/analyzer/analyzerbase.cpp @@ -72,7 +72,7 @@ void Analyzer::Base::showEvent(QShowEvent*) { timer_.start(timeout(), this); } void Analyzer::Base::transform(Scope& scope) { QVector aux(fht_->size()); - if ((long unsigned int)aux.size() >= scope.size()) { + if (static_cast(aux.size()) >= scope.size()) { std::copy(scope.begin(), scope.end(), aux.begin()); } else { @@ -97,7 +97,7 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) { int i = 0; // convert to mono here - our built in analyzers need mono, but the engines provide interleaved pcm - for (uint x = 0; (int)x < fht_->size(); ++x) { + for (uint x = 0; static_cast(x) < fht_->size(); ++x) { lastscope_[x] = double(thescope[i] + thescope[i + 1]) / (2 * (1 << 15)); i += 2; } @@ -188,11 +188,11 @@ void Analyzer::Base::polishEvent() { void Analyzer::interpolate(const Scope& inVec, Scope& outVec) { double pos = 0.0; - const double step = (double)inVec.size() / outVec.size(); + const double step = static_cast(inVec.size()) / outVec.size(); for (uint i = 0; i < outVec.size(); ++i, pos += step) { const double error = pos - std::floor(pos); - const uint64_t offset = (uint64_t)pos; + const uint64_t offset = static_cast(pos); uint64_t indexLeft = offset + 0; diff --git a/src/analyzer/blockanalyzer.cpp b/src/analyzer/blockanalyzer.cpp index 64f35c35f..0751b9e40 100644 --- a/src/analyzer/blockanalyzer.cpp +++ b/src/analyzer/blockanalyzer.cpp @@ -388,8 +388,8 @@ void BlockAnalyzer::drawBackground() { if (!p.paintEngine()) return; - for (int x = 0; (uint)x < columns_; ++x) - for (int y = 0; (uint)y < rows_; ++y) + for (int x = 0; static_cast(x) < columns_; ++x) + for (int y = 0; static_cast(y) < rows_; ++y) p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight, bgdark); } diff --git a/src/context/contextview.cpp b/src/context/contextview.cpp index 8aecb6469..eb3b7a0c1 100644 --- a/src/context/contextview.cpp +++ b/src/context/contextview.cpp @@ -711,7 +711,7 @@ void ContextView::ResetSong() { void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics) { - if ((qint64) id != lyrics_id_) return; + if (static_cast(id) != lyrics_id_) return; lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n"; lyrics_id_ = -1; if (action_show_lyrics_->isChecked()) { diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 0bcb38438..a6eae2a97 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -1682,7 +1682,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex } else { - Playlist::Column column = (Playlist::Column)index.column(); + Playlist::Column column = static_cast(index.column()); bool column_is_editable = Playlist::column_is_editable(column) && editable; ui_->action_selection_set_value->setVisible(ui_->action_selection_set_value->isVisible() && column_is_editable); @@ -1867,7 +1867,7 @@ void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelI void MainWindow::SelectionSetValue() { - Playlist::Column column = (Playlist::Column)playlist_menu_index_.column(); + Playlist::Column column = static_cast(playlist_menu_index_.column()); QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_); for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) { diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 1309f6549..8144d0352 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -875,7 +875,7 @@ QString UnicodeToAscii(const QString &unicode) { #endif iconv_t conv = iconv_open("ASCII//TRANSLIT", "UTF-8"); - if (conv == (iconv_t) -1) return unicode; + if (conv == reinterpret_cast(-1)) return unicode; QByteArray utf8 = unicode.toUtf8(); diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index 3a2ba8a6b..aa1774fe0 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -294,13 +294,13 @@ void AlbumCoverChoiceController::ShowCover(const Song &song, const QPixmap &pixm // Resize differently if monitor is in portrait mode if (desktop_width < desktop_height) { - const int new_width = (double)desktop_width * 0.95; + const int new_width = static_cast(desktop_width) * 0.95; if (new_width < pixmap.width()) { label->setPixmap(pixmap.scaledToWidth(new_width, Qt::SmoothTransformation)); } } else { - const int new_height = (double)desktop_height * 0.85; + const int new_height = static_cast(desktop_height) * 0.85; if (new_height < pixmap.height()) { label->setPixmap(pixmap.scaledToHeight(new_height, Qt::SmoothTransformation)); } diff --git a/src/device/cddasongloader.cpp b/src/device/cddasongloader.cpp index b4064206b..29eb06158 100644 --- a/src/device/cddasongloader.cpp +++ b/src/device/cddasongloader.cpp @@ -152,7 +152,7 @@ void CddaSongLoader::LoadSongs() { GstMessage *msg = nullptr; GstMessage *msg_toc = nullptr; GstMessage *msg_tag = nullptr; - while ((msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS(pipeline), GST_SECOND, (GstMessageType)(GST_MESSAGE_TOC | GST_MESSAGE_TAG)))) { + while ((msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS(pipeline), GST_SECOND, static_cast(GST_MESSAGE_TOC | GST_MESSAGE_TAG)))) { if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_TOC) { if (msg_toc) gst_message_unref(msg_toc); // Shouldn't happen, but just in case msg_toc = msg; @@ -169,7 +169,7 @@ void CddaSongLoader::LoadSongs() { gst_message_parse_toc (msg_toc, &toc, nullptr); if (toc) { GList *entries = gst_toc_get_entries(toc); - if (entries && (guint)songs.size() <= g_list_length(entries)) { + if (entries && static_cast(songs.size()) <= g_list_length(entries)) { int i = 0; for (GList *node = entries; node != nullptr; node = node->next) { GstTocEntry *entry = static_cast(node->data); diff --git a/src/device/giolister.cpp b/src/device/giolister.cpp index c3e9bb6a5..0805c23ff 100644 --- a/src/device/giolister.cpp +++ b/src/device/giolister.cpp @@ -52,7 +52,7 @@ QString GioLister::DeviceInfo::unique_id() const { if (mount_ptr) return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size); else - return QString("Gio/unmounted/%1").arg((qulonglong)volume_ptr.get()); + return QString("Gio/unmounted/%1").arg(reinterpret_cast(volume_ptr.get())); } @@ -609,7 +609,7 @@ void GioLister::UnmountDevice(const QString &id) { if (info.volume_ptr) { if (g_volume_can_eject(info.volume_ptr)) { - g_volume_eject_with_operation(info.volume_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)VolumeEjectFinished, nullptr); + g_volume_eject_with_operation(info.volume_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast(VolumeEjectFinished), nullptr); g_object_unref(info.volume_ptr); return; } @@ -617,10 +617,10 @@ void GioLister::UnmountDevice(const QString &id) { else return; if (g_mount_can_eject(info.mount_ptr)) { - g_mount_eject_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountEjectFinished, nullptr); + g_mount_eject_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast(MountEjectFinished), nullptr); } else if (g_mount_can_unmount(info.mount_ptr)) { - g_mount_unmount_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountUnmountFinished, nullptr); + g_mount_unmount_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast(MountUnmountFinished), nullptr); } } diff --git a/src/device/mtpconnection.cpp b/src/device/mtpconnection.cpp index f199c6919..7eace3c20 100644 --- a/src/device/mtpconnection.cpp +++ b/src/device/mtpconnection.cpp @@ -60,7 +60,7 @@ MtpConnection::MtpConnection(const QUrl &url) : device_(nullptr) { } if (url_query.hasQueryItem("vendor")) { - LIBMTP_raw_device_t *raw_device = (LIBMTP_raw_device_t*)malloc(sizeof(LIBMTP_raw_device_t)); + LIBMTP_raw_device_t *raw_device = static_cast(malloc(sizeof(LIBMTP_raw_device_t))); raw_device->device_entry.vendor = url_query.queryItemValue("vendor").toLatin1().data(); raw_device->device_entry.product = url_query.queryItemValue("product").toLatin1().data(); raw_device->device_entry.vendor_id = url_query.queryItemValue("vendor_id").toUShort(); diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 776c2f92d..738d941bf 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -321,7 +321,7 @@ const Engine::Scope &GstEngine::scope(const int chunk_length) { // The new buffer could have a different size if (have_new_buffer_) { if (latest_buffer_) { - scope_chunks_ = ceil(((double)GST_BUFFER_DURATION(latest_buffer_) / (double)(chunk_length * kNsecPerMsec))); + scope_chunks_ = ceil((static_cast(GST_BUFFER_DURATION(latest_buffer_) / static_cast(chunk_length * kNsecPerMsec)))); } // if the buffer is shorter than the chunk length @@ -514,7 +514,7 @@ void GstEngine::HandlePipelineError(const int pipeline_id, const QString &messag BufferingFinished(); emit StateChanged(Engine::Error); - if (domain == (int)GST_RESOURCE_ERROR && (error_code == (int)GST_RESOURCE_ERROR_NOT_FOUND || error_code == (int)GST_RESOURCE_ERROR_NOT_AUTHORIZED)) { + if (domain == static_cast(GST_RESOURCE_ERROR) && (error_code == static_cast(GST_RESOURCE_ERROR_NOT_FOUND) || error_code == static_cast(GST_RESOURCE_ERROR_NOT_AUTHORIZED))) { emit InvalidSongRequested(stream_url_); } else { diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index e5b5d67e1..b67e17d70 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -581,13 +581,13 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf GstMapInfo map_info; gst_buffer_map(buf, &map_info, GST_MAP_READ); - int32_t *s = (int32_t*) map_info.data; + int32_t *s = reinterpret_cast(map_info.data); int samples = (map_info.size / sizeof(int32_t)) / channels; int buf16_size = samples * sizeof(int16_t) * channels; - int16_t *d = (int16_t*) g_malloc(buf16_size); + int16_t *d = static_cast(g_malloc(buf16_size)); memset(d, 0, buf16_size); for (int i = 0 ; i < (samples * channels) ; ++i) { - d[i] = (int16_t) (s[i] >> 16); + d[i] = static_cast((s[i] >> 16)); } gst_buffer_unmap(buf, &map_info); buf16 = gst_buffer_new_wrapped(d, buf16_size); @@ -801,7 +801,7 @@ void GstEnginePipeline::ErrorMessageReceived(GstMessage *msg) { g_error_free(error); g_free(debugs); - if (state() == GST_STATE_PLAYING && pipeline_is_initialised_ && next_uri_set_ && (domain == (int)GST_RESOURCE_ERROR || domain == (int)GST_STREAM_ERROR)) { + if (state() == GST_STATE_PLAYING && pipeline_is_initialised_ && next_uri_set_ && (domain == static_cast(GST_RESOURCE_ERROR) || domain == static_cast(GST_STREAM_ERROR))) { // A track is still playing and the next uri is not playable. We ignore the error here so it can play until the end. // But there is no message send to the bus when the current track finishes, we have to add an EOS ourself. qLog(Debug) << "Ignoring error when loading next track"; @@ -1187,7 +1187,7 @@ void GstEnginePipeline::StreamDiscovered(GstDiscoverer*, GstDiscovererInfo *info GList *audio_streams = gst_discoverer_info_get_audio_streams(info); if (audio_streams) { - GstDiscovererStreamInfo *stream_info = (GstDiscovererStreamInfo*) g_list_first(audio_streams)->data; + GstDiscovererStreamInfo *stream_info = reinterpret_cast(g_list_first(audio_streams)->data); Engine::SimpleMetaBundle bundle; if (discovered_url == instance->stream_url_) { diff --git a/src/engine/xineengine.cpp b/src/engine/xineengine.cpp index 49d743b13..b052acb27 100644 --- a/src/engine/xineengine.cpp +++ b/src/engine/xineengine.cpp @@ -212,7 +212,7 @@ bool XineEngine::CreateStream() { if (eventqueue_) xine_event_dispose_queue(eventqueue_); eventqueue_ = xine_event_new_queue(stream_); - xine_event_create_listener_thread(eventqueue_, &XineEngine::XineEventListener, (void*)this); + xine_event_create_listener_thread(eventqueue_, &XineEngine::XineEventListener, reinterpret_cast(this)); #ifndef XINE_SAFE_MODE xine_set_param(stream_, XINE_PARAM_METRONOM_PREBUFFER, 6000); @@ -644,7 +644,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { case XINE_EVENT_PROGRESS: { - xine_progress_data_t *pd = (xine_progress_data_t*)event->data; + xine_progress_data_t *pd = reinterpret_cast(event->data); QString msg = QString("%1 %2%").arg(QString::fromUtf8(pd->description)).arg(QString::number(pd->percent) + QLocale::system().percent()); //qLog(Debug) << "Xine:" << msg; } @@ -664,7 +664,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { { qLog(Debug) << "XINE_EVENT_UI_MESSAGE"; - xine_ui_message_data_t *data = (xine_ui_message_data_t *)event->data; + xine_ui_message_data_t *data = reinterpret_cast(event->data); QString message; switch (data->type) { @@ -685,7 +685,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Source is encrypted."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -694,7 +694,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "The host is unknown."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -703,7 +703,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "The device name you specified seems invalid."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -712,7 +712,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "The network appears unreachable."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -721,7 +721,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Audio output unavailable; the device is busy."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->FatalError(); @@ -730,7 +730,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Connection refused."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -739,7 +739,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "File not found."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -748,7 +748,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Access denied."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -757,7 +757,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Read error."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->InvalidSongRequested(engine->stream_url_); @@ -766,7 +766,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "A problem occurred while loading a library or decoder."; if (data->explanation) { message += " : "; - message += QString::fromUtf8((char*)data + data->parameters); + message += QString::fromUtf8(reinterpret_cast(data) + data->parameters); } emit engine->StateChanged(Engine::Error); emit engine->FatalError(); @@ -775,7 +775,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "General Warning"; if (data->explanation) { message += ": "; - message += QString::fromUtf8((char*)data + data->explanation); + message += QString::fromUtf8(reinterpret_cast(data) + data->explanation); } else message += "."; break; @@ -783,7 +783,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Security Warning"; if (data->explanation) { message += ": "; - message += QString::fromUtf8((char*)data + data->explanation); + message += QString::fromUtf8(reinterpret_cast(data) + data->explanation); } else message += "."; break; @@ -791,7 +791,7 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) { message = "Unknown Error"; if (data->explanation) { message += ": "; - message += QString::fromUtf8((char*)data + data->explanation); + message += QString::fromUtf8(reinterpret_cast(data) + data->explanation); } else message += "."; break; diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 1a435079f..adce8d72e 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -177,7 +177,7 @@ QVariant Playlist::headerData(int section, Qt::Orientation, int role) const { if (role != Qt::DisplayRole && role != Qt::ToolTipRole) return QVariant(); - const QString name = column_name((Playlist::Column)section); + const QString name = column_name(static_cast(section)); if (!name.isEmpty()) return name; return QVariant(); @@ -375,7 +375,7 @@ bool Playlist::setData(const QModelIndex &index, const QVariant &value, int role if (index.data() == value) return false; - if (!set_column_value(song, (Column)index.column(), value)) return false; + if (!set_column_value(song, static_cast(index.column()), value)) return false; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(index)); @@ -655,7 +655,7 @@ Qt::ItemFlags Playlist::flags(const QModelIndex &index) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (column_is_editable((Column)index.column())) flags |= Qt::ItemIsEditable; + if (column_is_editable(static_cast(index.column()))) flags |= Qt::ItemIsEditable; if (index.isValid()) return flags | Qt::ItemIsDragEnabled; @@ -718,7 +718,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro stream.readRawData(reinterpret_cast(&source_playlist), sizeof(source_playlist)); stream >> source_rows; if (!stream.atEnd()) { - stream.readRawData((char*)&pid, sizeof(pid)); + stream.readRawData(reinterpret_cast(&pid), sizeof(pid)); } else { pid = !own_pid; @@ -1097,7 +1097,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const { stream.writeRawData(reinterpret_cast(&self), sizeof(self)); stream << rows; - stream.writeRawData((char*)&pid, sizeof(pid)); + stream.writeRawData(reinterpret_cast(&pid), sizeof(pid)); buf.close(); mimedata->setUrls(urls); diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp index 8b47ab504..3e490a743 100644 --- a/src/settings/collectionsettingspage.cpp +++ b/src/settings/collectionsettingspage.cpp @@ -173,10 +173,10 @@ void CollectionSettingsPage::Load() { ui_->checkbox_cover_replace_spaces->setChecked(s.value("cover_replace_spaces", true).toBool()); ui_->spinbox_cache_size->setValue(s.value(kSettingsCacheSize, kSettingsCacheSizeDefault).toInt()); - ui_->combobox_cache_size->setCurrentIndex(s.value(kSettingsCacheSizeUnit, (int) CacheSizeUnit_MB).toInt()); + ui_->combobox_cache_size->setCurrentIndex(s.value(kSettingsCacheSizeUnit, static_cast(CacheSizeUnit_MB)).toInt()); ui_->checkbox_disk_cache->setChecked(s.value(kSettingsDiskCacheEnable, false).toBool()); ui_->spinbox_disk_cache_size->setValue(s.value(kSettingsDiskCacheSize, kSettingsDiskCacheSizeDefault).toInt()); - ui_->combobox_disk_cache_size->setCurrentIndex(s.value(kSettingsDiskCacheSizeUnit, (int) CacheSizeUnit_MB).toInt()); + ui_->combobox_disk_cache_size->setCurrentIndex(s.value(kSettingsDiskCacheSizeUnit, static_cast(CacheSizeUnit_MB)).toInt()); s.endGroup(); diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index bf55afcb9..35562ebeb 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -76,7 +76,7 @@ class FancyTabBar: public QTabBar { QSize size(QTabBar::sizeHint()); - FancyTabWidget *tabWidget = (FancyTabWidget*) parentWidget(); + FancyTabWidget *tabWidget = qobject_cast(parentWidget()); if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) return size; QSize tabSize(tabSizeHint(0)); @@ -95,7 +95,7 @@ class FancyTabBar: public QTabBar { protected: QSize tabSizeHint(int index) const { - FancyTabWidget *tabWidget = (FancyTabWidget*) parentWidget(); + FancyTabWidget *tabWidget = qobject_cast(parentWidget()); QSize size = FancyTabWidget::TabSize_LargeSidebar; if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) { @@ -126,7 +126,7 @@ class FancyTabBar: public QTabBar { void paintEvent(QPaintEvent *pe) { - FancyTabWidget *tabWidget = (FancyTabWidget*) parentWidget(); + FancyTabWidget *tabWidget = qobject_cast(parentWidget()); bool verticalTextTabs = false;