diff --git a/ext/libstrawberry-common/core/messagehandler.h b/ext/libstrawberry-common/core/messagehandler.h index aa900973..5846f476 100644 --- a/ext/libstrawberry-common/core/messagehandler.h +++ b/ext/libstrawberry-common/core/messagehandler.h @@ -37,8 +37,8 @@ #define DataCommaSizeFromQString(x) x.toUtf8().constData(), x.toUtf8().length() // Reads and writes uint32 length encoded protobufs to a socket. -// This base QObject is separate from AbstractMessageHandler because moc can't -// handle templated classes. Use AbstractMessageHandler instead. +// This base QObject is separate from AbstractMessageHandler because moc can't handle templated classes. +// Use AbstractMessageHandler instead. class _MessageHandlerBase : public QObject { Q_OBJECT @@ -76,8 +76,7 @@ protected: }; // Reads and writes uint32 length encoded MessageType messages to a socket. -// You should subclass this and implement the MessageArrived(MessageType) -// method. +// You should subclass this and implement the MessageArrived(MessageType) method. template class AbstractMessageHandler : public _MessageHandlerBase { public: @@ -87,21 +86,19 @@ public: typedef MT MessageType; typedef MessageReply ReplyType; - // Serialises the message and writes it to the socket. This version MUST be - // called from the thread in which the AbstractMessageHandler was created. + // Serialises the message and writes it to the socket. + // This version MUST be called from the thread in which the AbstractMessageHandler was created. void SendMessage(const MessageType &message); - // Serialises the message and writes it to the socket. This version may be - // called from any thread. + // Serialises the message and writes it to the socket. + // This version may be called from any thread. void SendMessageAsync(const MessageType &message); // Sends the request message inside and takes ownership of the MessageReply. - // The MessageReply's Finished() signal will be emitted when a reply arrives - // with the same ID. Must be called from my thread. + // The MessageReply's Finished() signal will be emitted when a reply arrives with the same ID. Must be called from my thread. void SendRequest(ReplyType *reply); - // Sets the "id" field of reply to the same as the request, and sends the - // reply on the socket. Used on the worker side. + // Sets the "id" field of reply to the same as the request, and sends the reply on the socket. Used on the worker side. void SendReply(const MessageType &request, MessageType *reply); protected: @@ -131,8 +128,7 @@ void AbstractMessageHandler::SendMessage(const MessageType &message) { template void AbstractMessageHandler::SendMessageAsync(const MessageType &message) { std::string data = message.SerializeAsString(); - metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection, - Q_ARG(QByteArray, QByteArray(data.data(), data.size()))); + metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray(data.data(), data.size()))); } template @@ -159,7 +155,8 @@ bool AbstractMessageHandler::RawMessageArrived(const QByteArray &data) { if (reply) { // This is a reply to a message that we created earlier. reply->SetReply(message); - } else { + } + else { MessageArrived(message); } diff --git a/ext/libstrawberry-common/core/waitforsignal.h b/ext/libstrawberry-common/core/waitforsignal.h index 78fa1757..c7fbc38b 100644 --- a/ext/libstrawberry-common/core/waitforsignal.h +++ b/ext/libstrawberry-common/core/waitforsignal.h @@ -22,4 +22,4 @@ class QObject; void WaitForSignal(QObject *sender, const char *signal); -#endif // WAITFORSIGNAL_H +#endif // WAITFORSIGNAL_H diff --git a/ext/libstrawberry-common/core/workerpool.h b/ext/libstrawberry-common/core/workerpool.h index 30a805ec..b34bf3a7 100644 --- a/ext/libstrawberry-common/core/workerpool.h +++ b/ext/libstrawberry-common/core/workerpool.h @@ -114,8 +114,7 @@ private: template Worker *FindWorker(T Worker::*member, T value) { - for (typename QList::iterator it = workers_.begin() ; - it != workers_.end() ; ++it) { + for (typename QList::iterator it = workers_.begin() ; it != workers_.end() ; ++it) { if ((*it).*member == value) { return &(*it); } @@ -158,8 +157,7 @@ template WorkerPool::WorkerPool(QObject *parent) : _WorkerPoolBase(parent), next_worker_(0), - next_id_(0) -{ + next_id_(0) { worker_count_ = qBound(1, QThread::idealThreadCount() / 2, 2); local_server_name_ = qApp->applicationName().toLower(); @@ -396,4 +394,3 @@ HandlerType *WorkerPool::NextHandler() const { } #endif // WORKERPOOL_H - diff --git a/ext/strawberry-tagreader/tagreaderworker.h b/ext/strawberry-tagreader/tagreaderworker.h index c90d8704..8ced818a 100644 --- a/ext/strawberry-tagreader/tagreaderworker.h +++ b/ext/strawberry-tagreader/tagreaderworker.h @@ -41,4 +41,4 @@ private: TagReader tag_reader_; }; -#endif // TAGREADERWORKER_H +#endif // TAGREADERWORKER_H diff --git a/src/core/database.cpp b/src/core/database.cpp index f30a34c8..a59713a0 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -595,7 +595,8 @@ bool Database::IntegrityCheck(QSqlDatabase db) { if (message == "ok") { ok = true; break; - } else { + } + else { if (!error_reported) { app_->AddError(tr("Database corruption detected.")); } app_->AddError("Database: " + message); error_reported = true; @@ -677,9 +678,9 @@ void Database::BackupFile(const QString &filename) { do { ret = sqlite3_backup_step(backup, 16); const int page_count = sqlite3_backup_pagecount(backup); - app_->task_manager()->SetTaskProgress( - task_id, page_count - sqlite3_backup_remaining(backup), page_count); - } while (ret == SQLITE_OK); + app_->task_manager()->SetTaskProgress(task_id, page_count - sqlite3_backup_remaining(backup), page_count); + } + while (ret == SQLITE_OK); if (ret != SQLITE_DONE) { qLog(Error) << "Database backup failed"; diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index d4ce5ed9..bf889974 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -1321,7 +1321,7 @@ void MainWindow::AddToPlaylist(QAction *action) { } SongList songs; - for (const PlaylistItemPtr &item : items) { + for (const PlaylistItemPtr item : items) { songs << item->Metadata(); } @@ -1587,7 +1587,7 @@ void MainWindow::EditTracks() { void MainWindow::EditTagDialogAccepted() { - for (const PlaylistItemPtr &item : edit_tag_dialog_->playlist_items()) { + for (const PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) { item->Reload(); } @@ -2256,7 +2256,7 @@ void MainWindow::AutoCompleteTags() { void MainWindow::AutoCompleteTagsAccepted() { - for (const PlaylistItemPtr &item : autocomplete_tag_items_) { + for (const PlaylistItemPtr item : autocomplete_tag_items_) { item->Reload(); } diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 761a264a..b764fe11 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -265,8 +265,6 @@ bool RemoveRecursive(const QString &path) { return dir.rmdir(path); - return true; - } bool CopyRecursive(const QString &source, const QString &destination) { diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 0c8e050f..9bfe637f 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -861,7 +861,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n // exercise vetoes SongList songs; - for (const PlaylistItemPtr &item : items) { + for (const PlaylistItemPtr item : items) { songs << item->Metadata(); } @@ -1736,7 +1736,7 @@ QSortFilterProxyModel *Playlist::proxy() const { return proxy_; } SongList Playlist::GetAllSongs() const { SongList ret; - for (const PlaylistItemPtr &item : items_) { + for (const PlaylistItemPtr item : items_) { ret << item->Metadata(); } return ret; @@ -1746,7 +1746,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; } quint64 Playlist::GetTotalLength() const { quint64 ret = 0; - for (const PlaylistItemPtr &item : items_) { + for (const PlaylistItemPtr item : items_) { quint64 length = item->Metadata().length_nanosec(); if (length > 0) ret += length; } diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index 6eea815a..832e6d32 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -292,7 +292,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items, if (db_->CheckErrors(clear)) return; // Save the new ones - for (const PlaylistItemPtr &item : items) { + for (const PlaylistItemPtr item : items) { insert.bindValue(":playlist", playlist); item->BindToQuery(&insert); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 7e7f9065..63273412 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -451,7 +451,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) { for (const Song &song : songs) { for (const Data &data : playlists_) { PlaylistItemList items = data.p->collection_items_by_id(song.id()); - for (PlaylistItemPtr &item : items) { + for (const PlaylistItemPtr item : items) { if (item->Metadata().directory_id() != song.directory_id()) continue; static_cast(item.get())->SetMetadata(song); data.p->ItemChanged(item);