diff --git a/ext/libstrawberry-common/core/logging.cpp b/ext/libstrawberry-common/core/logging.cpp index a6c91d858..515b99af6 100644 --- a/ext/libstrawberry-common/core/logging.cpp +++ b/ext/libstrawberry-common/core/logging.cpp @@ -126,7 +126,8 @@ class LoggedDebug : public DebugBase { static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QString &message) { if (message.startsWith(kMessageHandlerMagic)) { - fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", message.toUtf8().data() + kMessageHandlerMagicLength); + QByteArray message_data = message.toUtf8(); + fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", message_data.constData() + kMessageHandlerMagicLength); fflush(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout); return; } diff --git a/ext/libstrawberry-tagreader/tagreadergme.cpp b/ext/libstrawberry-tagreader/tagreadergme.cpp index 132a0ccd2..ce996d247 100644 --- a/ext/libstrawberry-tagreader/tagreadergme.cpp +++ b/ext/libstrawberry-tagreader/tagreadergme.cpp @@ -200,7 +200,7 @@ void GME::VGM::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so QByteArray gd3_head = file.read(4); if (gd3_head.size() < 4) return; - quint64 pt = GME::UnpackBytes32(gd3_head, gd3_head.size()); + quint64 pt = GME::UnpackBytes32(gd3_head.constData(), gd3_head.size()); file.seek(SAMPLE_COUNT); QByteArray sample_count_bytes = file.read(4); @@ -215,7 +215,7 @@ void GME::VGM::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so file.seek(file.pos() + 4); QByteArray gd3_length_bytes = file.read(4); - quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes, gd3_length_bytes.size()); + quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes.constData(), gd3_length_bytes.size()); QByteArray gd3Data = file.read(gd3_length); QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly); @@ -246,11 +246,11 @@ bool GME::VGM::GetPlaybackLength(const QByteArray &sample_count_bytes, const QBy if (sample_count_bytes.size() != 4) return false; if (loop_count_bytes.size() != 4) return false; - quint64 sample_count = GME::UnpackBytes32(sample_count_bytes, sample_count_bytes.size()); + quint64 sample_count = GME::UnpackBytes32(sample_count_bytes.constData(), sample_count_bytes.size()); if (sample_count <= 0) return false; - quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes, loop_count_bytes.size()); + quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes.constData(), loop_count_bytes.size()); if (loop_sample_count <= 0) { out_length = sample_count * 1000 / SAMPLE_TIMEBASE; diff --git a/src/core/database.cpp b/src/core/database.cpp index 94da3e1cb..1b0980adf 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -536,7 +536,8 @@ void Database::DoBackup() { bool Database::OpenDatabase(const QString &filename, sqlite3 **connection) { - int ret = sqlite3_open(filename.toUtf8(), connection); + const QByteArray filename_data = filename.toUtf8(); + int ret = sqlite3_open(filename_data.constData(), connection); if (ret != 0) { if (*connection) { const char *error_message = sqlite3_errmsg(*connection); diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 1b381413b..14dc7d148 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -693,7 +693,8 @@ QString FiddleFileExtension(const QString &filename, const QString &new_extensio } QString GetEnv(const QString &key) { - return QString::fromLocal8Bit(qgetenv(key.toLocal8Bit())); + const QByteArray key_data = key.toLocal8Bit(); + return QString::fromLocal8Bit(qgetenv(key_data.constData())); } void SetEnv(const char *key, const QString &value) { diff --git a/src/device/deviceproperties.cpp b/src/device/deviceproperties.cpp index 8d18fbd58..5ce6be2a4 100644 --- a/src/device/deviceproperties.cpp +++ b/src/device/deviceproperties.cpp @@ -175,7 +175,7 @@ void DeviceProperties::UpdateHardwareInfo() { AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id)); keys = info.keys(); for (const QString &key : keys) { - AddHardwareInfo(row++, tr(key.toLatin1()), info[key].toString()); + AddHardwareInfo(row++, key, info[key].toString()); } ui_->hardware_info->sortItems(0); diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index 6a04163cc..1c22c88d3 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -203,7 +203,8 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) { cover_file->close(); QImage image = job.metadata_.image(); if (image.save(cover_file->fileName(), "JPG")) { - result = itdb_track_set_thumbnails(track, QFile::encodeName(cover_file->fileName())); + const QByteArray filename = QFile::encodeName(cover_file->fileName()); + result = itdb_track_set_thumbnails(track, filename.constData()); if (result) { cover_files_ << cover_file; track->has_artwork = 1; @@ -218,7 +219,8 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) { } } else if (!job.cover_source_.isEmpty()) { - result = itdb_track_set_thumbnails(track, QFile::encodeName(job.cover_source_)); + const QByteArray filename = QFile::encodeName(job.cover_source_); + result = itdb_track_set_thumbnails(track, filename.constData()); if (result) track->has_artwork = 1; } else { @@ -245,14 +247,15 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) { // Put the track in the playlist, if one is specified if (!job.playlist_.isEmpty()) { // Does the playlist already exist? - auto itdbPlaylist = itdb_playlist_by_name(db_, job.playlist_.toUtf8().data()); - if (itdbPlaylist == nullptr) { + QByteArray playlist_name = job.playlist_.toUtf8(); + Itdb_Playlist *playlist = itdb_playlist_by_name(db_, playlist_name.data()); + if (!playlist) { // Create the playlist - itdbPlaylist = itdb_playlist_new(job.playlist_.toUtf8().data(), false); - itdb_playlist_add(db_, itdbPlaylist, -1); + playlist = itdb_playlist_new(playlist_name.data(), false); + itdb_playlist_add(db_, playlist, -1); } // Playlist should exist so add the track to the playlist - itdb_playlist_add_track(itdbPlaylist, track, -1); + itdb_playlist_add_track(playlist, track, -1); } AddTrackToModel(track, url_.path()); diff --git a/src/device/gpodloader.cpp b/src/device/gpodloader.cpp index 91ddcf136..896ac4980 100644 --- a/src/device/gpodloader.cpp +++ b/src/device/gpodloader.cpp @@ -65,8 +65,9 @@ void GPodLoader::LoadDatabase() { Itdb_iTunesDB *GPodLoader::TryLoad() { // Load the iTunes database + const QByteArray mountpoint = QDir::toNativeSeparators(mount_point_).toLocal8Bit(); GError *error = nullptr; - Itdb_iTunesDB *db = itdb_parse(QDir::toNativeSeparators(mount_point_).toLocal8Bit(), &error); + Itdb_iTunesDB *db = itdb_parse(mountpoint.constData(), &error); // Check for errors if (!db) { diff --git a/src/internet/localredirectserver.cpp b/src/internet/localredirectserver.cpp index 0cb3dc2b1..74463cb6a 100644 --- a/src/internet/localredirectserver.cpp +++ b/src/internet/localredirectserver.cpp @@ -352,7 +352,8 @@ void LocalRedirectServer::WriteTemplate() const { break; } - page_data.replace(offset, re_match.capturedLength(), tr(re_match.captured(1).toUtf8())); + const QByteArray captured_data = re_match.captured(1).toUtf8(); + page_data.replace(offset, re_match.capturedLength(), tr(captured_data.constData())); offset += re_match.capturedLength(); } diff --git a/src/main.cpp b/src/main.cpp index 33f9a61dd..d5d1c63b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -130,7 +130,8 @@ int main(int argc, char *argv[]) { #endif // This makes us show up nicely in gnome-volume-control - g_set_application_name(QCoreApplication::applicationName().toLocal8Bit()); + const QByteArray g_application_name = QCoreApplication::applicationName().toLocal8Bit(); + g_set_application_name(g_application_name.constData()); RegisterMetaTypes();