Skip to content

Commit

Permalink
Fix device loader error messages. (#6215)
Browse files Browse the repository at this point in the history
GPodLoader and MtpLoader Error signals were connected to Error signals in their repective device classes, but the actual signal definition in ConnectedDevice was removed in a refactor several years ago. This change adds LoaderError slots to these device classes and reports the error in the manner of the refactored code.
  • Loading branch information
jbroadus authored and hatstand committed Nov 28, 2018
1 parent c6cb733 commit 122d28e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/devices/gpoddevice.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void GPodDevice::Init() {
shared_from_this()); shared_from_this());
loader_->moveToThread(loader_thread_); loader_->moveToThread(loader_thread_);


connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(loader_, SIGNAL(Error(QString)), SLOT(LoaderError(QString)));
connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int))); connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int)));
connect(loader_, SIGNAL(LoadFinished(Itdb_iTunesDB*)), connect(loader_, SIGNAL(LoadFinished(Itdb_iTunesDB*)),
SLOT(LoadFinished(Itdb_iTunesDB*))); SLOT(LoadFinished(Itdb_iTunesDB*)));
Expand Down Expand Up @@ -223,6 +223,10 @@ void GPodDevice::FinishDelete(bool success) {
ConnectedDevice::FinishDelete(success); ConnectedDevice::FinishDelete(success);
} }


void GPodDevice::LoaderError(const QString& message) {
app_->AddError(message);
}

bool GPodDevice::GetSupportedFiletypes(QList<Song::FileType>* ret) { bool GPodDevice::GetSupportedFiletypes(QList<Song::FileType>* ret) {
*ret << Song::Type_Mp4; *ret << Song::Type_Mp4;
*ret << Song::Type_Mpeg; *ret << Song::Type_Mpeg;
Expand Down
1 change: 1 addition & 0 deletions src/devices/gpoddevice.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {


protected slots: protected slots:
void LoadFinished(Itdb_iTunesDB* db); void LoadFinished(Itdb_iTunesDB* db);
void LoaderError(const QString& message);


protected: protected:
Itdb_Track* AddTrackToITunesDb(const Song& metadata); Itdb_Track* AddTrackToITunesDb(const Song& metadata);
Expand Down
4 changes: 3 additions & 1 deletion src/devices/mtpdevice.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void MtpDevice::Init() {
new MtpLoader(url_, app_->task_manager(), backend_, shared_from_this()); new MtpLoader(url_, app_->task_manager(), backend_, shared_from_this());
loader_->moveToThread(loader_thread_); loader_->moveToThread(loader_thread_);


connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(loader_, SIGNAL(Error(QString)), SLOT(LoaderError(QString)));
connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int))); connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int)));
connect(loader_, SIGNAL(LoadFinished()), SLOT(LoadFinished())); connect(loader_, SIGNAL(LoadFinished()), SLOT(LoadFinished()));
connect(loader_thread_, SIGNAL(started()), loader_, SLOT(LoadDatabase())); connect(loader_thread_, SIGNAL(started()), loader_, SLOT(LoadDatabase()));
Expand All @@ -69,6 +69,8 @@ void MtpDevice::LoadFinished() {
db_busy_.unlock(); db_busy_.unlock();
} }


void MtpDevice::LoaderError(const QString& message) { app_->AddError(message); }

bool MtpDevice::StartCopy(QList<Song::FileType>* supported_types) { bool MtpDevice::StartCopy(QList<Song::FileType>* supported_types) {
// Ensure only one "organise files" can be active at any one time // Ensure only one "organise files" can be active at any one time
db_busy_.lock(); db_busy_.lock();
Expand Down
1 change: 1 addition & 0 deletions src/devices/mtpdevice.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MtpDevice : public ConnectedDevice {


private slots: private slots:
void LoadFinished(); void LoadFinished();
void LoaderError(const QString& message);


private: private:
bool GetSupportedFiletypes(QList<Song::FileType>* ret, bool GetSupportedFiletypes(QList<Song::FileType>* ret,
Expand Down

0 comments on commit 122d28e

Please sign in to comment.