Replace use of C style casts

This commit is contained in:
Jonas Kvinge 2020-06-15 17:59:02 +02:00
parent a68c249d4e
commit 72ede666d4
35 changed files with 105 additions and 111 deletions

View File

@ -306,7 +306,7 @@ void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
return;
}
if (sock->bytesAvailable() < (qint64) sizeof(quint64)) {
if (sock->bytesAvailable() < static_cast<qint64>(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<qint64>(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<qint64>(info.msgLen)) {
return;
}

View File

@ -306,7 +306,7 @@ void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
return;
}
if (sock->bytesAvailable() < (qint64)sizeof(quint64)) {
if (sock->bytesAvailable() < static_cast<qint64>(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<qint64>(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<qint64>(info.msgLen)) {
return;
}

View File

@ -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<int>(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<int>(d->type), false) +
ByteVector::fromUInt(data.size(), false) +
nameData +
data;

View File

@ -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<unsigned int>(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<unsigned int>(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<long>(readQWORD(this, &ok));
if (!ok) {
setValid(false);
break;

View File

@ -117,7 +117,7 @@ ByteVector ASF::Picture::render() const {
if (!isValid())
return ByteVector();
return ByteVector((char)d->type) +
return ByteVector(static_cast<char>(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<Type>(bytes[0]);
++pos;
const unsigned int dataLen = bytes.toUInt(pos, false);
pos += 4;

View File

@ -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<unsigned long long>(dstNumFrames) * static_cast<unsigned long long>(sampleRate) / static_cast<unsigned long long>(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()) {

View File

@ -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<long>(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<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
unsigned long sampleOffset = 0;
if (!readU32L(sampleOffset))
return false;
seek(sampleOffset + 20);
if ((unsigned int)(i + instrumentCount) < lines.size())
if (static_cast<unsigned int>(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<char>(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<char>(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<unsigned char>(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<long>(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<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
READ_U32L_AS(sampleOffset);
seek(sampleOffset);

View File

@ -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<char>(0));
if (index > -1) {
data.resize(index);
}

View File

@ -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<int>((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<int>(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<int>(data[0].toShort());
if (idx > 0) {
addItem("\251gen", StringList(ID3v1::genre(idx - 1)));
}

View File

@ -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<int>((64.82 - static_cast<short>(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<int>((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<int>(log10(static_cast<double>(d->trackPeak)) * 20 * 256 + .5);
if (d->albumPeak != 0)
d->albumPeak = (int)(log10((double)d->albumPeak) * 20 * 256 + .5);
d->albumPeak = static_cast<int>(log10(static_cast<double>(d->albumPeak)) * 20 * 256 + .5);
bool trueGapless = (gapless >> 31) & 0x0001;
if (trueGapless) {

View File

@ -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<ID3v2::AttachedPictureFrame::Type>(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<ID3v2::AttachedPictureFrame::Type>(data[pos++]);
d->description = readStringField(data, d->textEncoding, &pos);
d->data = data.mid(pos);

View File

@ -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<unsigned char>(data[pos++]);
if (pos < size) {
d->counter = data.toUInt(static_cast<unsigned int>(pos));
}

View File

@ -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<int>(data.size()) - 4) {
ChannelType type = ChannelType(data[pos]);
pos += 1;

View File

@ -309,7 +309,7 @@ ByteVector TableOfContentsFrame::renderFields() const {
if (d->isOrdered)
flags += 1;
data.append(flags);
data.append((char)(entryCount()));
data.append(static_cast<char>(entryCount()));
ByteVectorList::ConstIterator it = d->childElements.begin();
while (it != d->childElements.end()) {
data.append(*it);

View File

@ -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<long>(i) << 1));
unsigned short instrumentOffset = 0;
if (!readU16L(instrumentOffset))
return false;
seek(((long)instrumentOffset << 4) + 48);
seek((static_cast<long>(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<long>(i) << 1));
READ_U16L_AS(sampleHeaderOffset);
seek((long)sampleHeaderOffset << 4);
seek(static_cast<long>(sampleHeaderOffset) << 4);
READ_BYTE_AS(sampleType);
READ_STRING_AS(dosFileName, 13);

View File

@ -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<const unsigned char*>(input.data());
unsigned char *dst = reinterpret_cast<unsigned char*>(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<unsigned int>(dst - (unsigned char *)output.data()));
output.resize(static_cast<unsigned int>(dst - reinterpret_cast<unsigned char*>(output.data())));
return output;
}
return ByteVector();

View File

@ -115,7 +115,7 @@ class StringReader : public ValueReader<String> {
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<char>(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<unsigned long>(header.size()));
READ_ASSERT(count == size);

View File

@ -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<const gfloat*>(_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<const gdouble*>(_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<const gint32*>(_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<const gint16*>(_in);
for (j = 0; j < len; j++) {
out[op] = in[ip++] / max_value;

View File

@ -196,10 +196,10 @@ void SetLevels(const QString &levels) {
}
if (class_name.isEmpty() || class_name == "*") {
sDefaultLevel = (Level) level;
sDefaultLevel = static_cast<Level>(level);
}
else {
sClassLevels->insert(class_name, (Level) level);
sClassLevels->insert(class_name, static_cast<Level>(level));
}
}

View File

@ -803,7 +803,7 @@ QByteArray TagReader::LoadEmbeddedArt(const QString &filename) const {
TagLib::ID3v2::AttachedPictureFrame *pic = static_cast<TagLib::ID3v2::AttachedPictureFrame*>(apic_frames.front());
return QByteArray((const char*) pic->picture().data(), pic->picture().size());
return QByteArray(reinterpret_cast<const char*>(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<uint>(pos) < data.size())) {
ret = QByteArray(data.data() + pos, data.size() - pos);
}
}

View File

@ -72,7 +72,7 @@ void Analyzer::Base::showEvent(QShowEvent*) { timer_.start(timeout(), this); }
void Analyzer::Base::transform(Scope& scope) {
QVector<float> aux(fht_->size());
if ((long unsigned int)aux.size() >= scope.size()) {
if (static_cast<long unsigned int>(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<int>(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<double>(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<uint64_t>(pos);
uint64_t indexLeft = offset + 0;

View File

@ -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<uint>(x) < columns_; ++x)
for (int y = 0; static_cast<uint>(y) < rows_; ++y)
p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight, bgdark);
}

View File

@ -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<qint64>(id) != lyrics_id_) return;
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
lyrics_id_ = -1;
if (action_show_lyrics_->isChecked()) {

View File

@ -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<Playlist::Column>(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::Column>(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()) {

View File

@ -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<iconv_t>(-1)) return unicode;
QByteArray utf8 = unicode.toUtf8();

View File

@ -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<double>(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<double>(desktop_height) * 0.85;
if (new_height < pixmap.height()) {
label->setPixmap(pixmap.scaledToHeight(new_height, Qt::SmoothTransformation));
}

View File

@ -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<GstMessageType>(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<guint>(songs.size()) <= g_list_length(entries)) {
int i = 0;
for (GList *node = entries; node != nullptr; node = node->next) {
GstTocEntry *entry = static_cast<GstTocEntry*>(node->data);

View File

@ -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<qulonglong>(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<GAsyncReadyCallback>(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<GAsyncReadyCallback>(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<GAsyncReadyCallback>(MountUnmountFinished), nullptr);
}
}

View File

@ -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<LIBMTP_raw_device_t*>(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();

View File

@ -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<double>(GST_BUFFER_DURATION(latest_buffer_) / static_cast<double>(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<int>(GST_RESOURCE_ERROR) && (error_code == static_cast<int>(GST_RESOURCE_ERROR_NOT_FOUND) || error_code == static_cast<int>(GST_RESOURCE_ERROR_NOT_AUTHORIZED))) {
emit InvalidSongRequested(stream_url_);
}
else {

View File

@ -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<int32_t*>(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<int16_t*>(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<int16_t>((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<int>(GST_RESOURCE_ERROR) || domain == static_cast<int>(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<GstDiscovererStreamInfo*>(g_list_first(audio_streams)->data);
Engine::SimpleMetaBundle bundle;
if (discovered_url == instance->stream_url_) {

View File

@ -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<void*>(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<xine_progress_data_t*>(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<xine_ui_message_data_t*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(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<char*>(data) + data->explanation);
}
else message += ".";
break;

View File

@ -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<Playlist::Column>(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<Column>(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<Column>(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<char*>(&source_playlist), sizeof(source_playlist));
stream >> source_rows;
if (!stream.atEnd()) {
stream.readRawData((char*)&pid, sizeof(pid));
stream.readRawData(reinterpret_cast<char*>(&pid), sizeof(pid));
}
else {
pid = !own_pid;
@ -1097,7 +1097,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
stream.writeRawData(reinterpret_cast<char*>(&self), sizeof(self));
stream << rows;
stream.writeRawData((char*)&pid, sizeof(pid));
stream.writeRawData(reinterpret_cast<const char*>(&pid), sizeof(pid));
buf.close();
mimedata->setUrls(urls);

View File

@ -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<int>(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<int>(CacheSizeUnit_MB)).toInt());
s.endGroup();

View File

@ -76,7 +76,7 @@ class FancyTabBar: public QTabBar {
QSize size(QTabBar::sizeHint());
FancyTabWidget *tabWidget = (FancyTabWidget*) parentWidget();
FancyTabWidget *tabWidget = qobject_cast<FancyTabWidget*>(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<FancyTabWidget*>(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<FancyTabWidget*>(parentWidget());
bool verticalTextTabs = false;