Qt: fix canceling of thumbnail downloads, use QDir comparison instead of string-based to honor case-insensitivity on Windows

This commit is contained in:
Brad Parker 2018-08-28 09:01:25 -04:00
parent 96e14c0b61
commit 44eb97206a
6 changed files with 17 additions and 8 deletions

View File

@ -467,7 +467,8 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
menu->addMenu(hiddenPlaylistsMenu.data()); menu->addMenu(hiddenPlaylistsMenu.data());
if (currentPlaylistDirPath != playlistDirAbsPath) /* Don't just compare strings in case there are case differences on Windows that should be ignored. */
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
{ {
/* special playlists like history etc. can't have an association */ /* special playlists like history etc. can't have an association */
specialPlaylist = true; specialPlaylist = true;

View File

@ -50,6 +50,8 @@ void MainWindow::onPlaylistThumbnailDownloadNetworkSslErrors(const QList<QSslErr
void MainWindow::onPlaylistThumbnailDownloadCanceled() void MainWindow::onPlaylistThumbnailDownloadCanceled()
{ {
m_playlistThumbnailDownloadProgressDialog->cancel(); m_playlistThumbnailDownloadProgressDialog->cancel();
m_playlistThumbnailDownloadWasCanceled = true;
RARCH_LOG("[Qt]: Playlist thumbnail download was canceled.\n");
} }
void MainWindow::onPlaylistThumbnailDownloadFinished() void MainWindow::onPlaylistThumbnailDownloadFinished()
@ -147,7 +149,7 @@ void MainWindow::onPlaylistThumbnailDownloadFinished()
emit showErrorMessageDeferred(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NETWORK_ERROR)) + ": Code " + QString::number(code) + ": " + errorData);*/ emit showErrorMessageDeferred(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NETWORK_ERROR)) + ": Code " + QString::number(code) + ": " + errorData);*/
} }
if (m_pendingPlaylistThumbnails.count() > 0) if (!m_playlistThumbnailDownloadWasCanceled && m_pendingPlaylistThumbnails.count() > 0)
{ {
QHash<QString, QString> nextThumbnail = m_pendingPlaylistThumbnails.takeAt(0); QHash<QString, QString> nextThumbnail = m_pendingPlaylistThumbnails.takeAt(0);
ViewType viewType = getCurrentViewType(); ViewType viewType = getCurrentViewType();
@ -250,9 +252,7 @@ void MainWindow::downloadNextPlaylistThumbnail(QString system, QString title, QS
/* make sure any previous connection is removed first */ /* make sure any previous connection is removed first */
disconnect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); disconnect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
disconnect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), m_playlistThumbnailDownloadProgressDialog, SLOT(cancel()));
connect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); connect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
connect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), m_playlistThumbnailDownloadProgressDialog, SLOT(cancel()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onPlaylistThumbnailDownloadNetworkError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onPlaylistThumbnailDownloadNetworkError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onPlaylistThumbnailDownloadNetworkSslErrors(const QList<QSslError>&))); connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onPlaylistThumbnailDownloadNetworkSslErrors(const QList<QSslError>&)));
@ -287,6 +287,7 @@ void MainWindow::downloadPlaylistThumbnails(QString playlistPath)
m_pendingPlaylistThumbnails.clear(); m_pendingPlaylistThumbnails.clear();
m_downloadedThumbnails = 0; m_downloadedThumbnails = 0;
m_failedThumbnails = 0; m_failedThumbnails = 0;
m_playlistThumbnailDownloadWasCanceled = false;
if (playlistItems.count() == 0) if (playlistItems.count() == 0)
return; return;

View File

@ -285,9 +285,7 @@ void MainWindow::downloadThumbnail(QString system, QString title, QUrl url)
/* make sure any previous connection is removed first */ /* make sure any previous connection is removed first */
disconnect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); disconnect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
disconnect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailDownloadProgressDialog, SLOT(cancel()));
connect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); connect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
connect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailDownloadProgressDialog, SLOT(cancel()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onThumbnailDownloadNetworkError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onThumbnailDownloadNetworkError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onThumbnailDownloadNetworkSslErrors(const QList<QSslError>&))); connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onThumbnailDownloadNetworkSslErrors(const QList<QSslError>&)));

View File

@ -284,9 +284,7 @@ void MainWindow::downloadAllThumbnails(QString system, QUrl url)
/* make sure any previous connection is removed first */ /* make sure any previous connection is removed first */
disconnect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); disconnect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
disconnect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailPackDownloadProgressDialog, SLOT(cancel()));
connect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort())); connect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
connect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailPackDownloadProgressDialog, SLOT(cancel()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onThumbnailPackDownloadNetworkError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onThumbnailPackDownloadNetworkError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onThumbnailPackDownloadNetworkSslErrors(const QList<QSslError>&))); connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onThumbnailPackDownloadNetworkSslErrors(const QList<QSslError>&)));

View File

@ -333,6 +333,7 @@ MainWindow::MainWindow(QWidget *parent) :
,m_pendingPlaylistThumbnails() ,m_pendingPlaylistThumbnails()
,m_downloadedThumbnails(0) ,m_downloadedThumbnails(0)
,m_failedThumbnails(0) ,m_failedThumbnails(0)
,m_playlistThumbnailDownloadWasCanceled(false)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist); QDir playlistDir(settings->paths.directory_playlist);
@ -555,6 +556,15 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList))); connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
connect(m_gridLayoutWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&))); connect(m_gridLayoutWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));
connect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), m_playlistThumbnailDownloadProgressDialog, SLOT(cancel()));
connect(m_playlistThumbnailDownloadProgressDialog, SIGNAL(canceled()), this, SLOT(onPlaylistThumbnailDownloadCanceled()));
connect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailDownloadProgressDialog, SLOT(cancel()));
connect(m_thumbnailDownloadProgressDialog, SIGNAL(canceled()), this, SLOT(onThumbnailDownloadCanceled()));
connect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), m_thumbnailPackDownloadProgressDialog, SLOT(cancel()));
connect(m_thumbnailPackDownloadProgressDialog, SIGNAL(canceled()), this, SLOT(onThumbnailPackDownloadCanceled()));
connect(this, SIGNAL(itemChanged()), this, SLOT(onItemChanged())); connect(this, SIGNAL(itemChanged()), this, SLOT(onItemChanged()));
connect(this, SIGNAL(gridItemChanged(QString)), this, SLOT(onGridItemChanged(QString))); connect(this, SIGNAL(gridItemChanged(QString)), this, SLOT(onGridItemChanged(QString)));
connect(this, SIGNAL(gotThumbnailDownload(QString,QString)), this, SLOT(onDownloadThumbnail(QString,QString))); connect(this, SIGNAL(gotThumbnailDownload(QString,QString)), this, SLOT(onDownloadThumbnail(QString,QString)));

View File

@ -506,6 +506,7 @@ private:
QVector<QHash<QString, QString> > m_pendingPlaylistThumbnails; QVector<QHash<QString, QString> > m_pendingPlaylistThumbnails;
unsigned m_downloadedThumbnails; unsigned m_downloadedThumbnails;
unsigned m_failedThumbnails; unsigned m_failedThumbnails;
bool m_playlistThumbnailDownloadWasCanceled;
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);