From 8c6bc4a6780f0bf89a34387e709a986cbac71d82 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 28 May 2018 18:14:36 -0400 Subject: [PATCH] Qt: update UI after loading every 25 grid items, keep grid from mixing up content from multiple playlists if the user switches to a new one before one is finished loading --- ui/drivers/qt/ui_qt_window.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 56ed1c463b..f4db64cb15 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2999,6 +2999,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) QVector > items = getPlaylistItems(pathString); QScreen *screen = qApp->primaryScreen(); QSize screenSize = screen->size(); + QListWidgetItem *currentItem = m_listWidget->currentItem(); settings_t *settings = config_get_ptr(); int i = 0; int zoomValue = m_zoomSlider->value(); @@ -3006,7 +3007,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) for (i = 0; i < items.count(); i++) { const QHash &hash = items.at(i); - QPointer item (new GridItem()); + QPointer item; QPointer label; QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; @@ -3016,6 +3017,14 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) QString imagePath; int lastIndex = -1; + if (m_listWidget->currentItem() != currentItem) + { + /* user changed the current playlist before we finished loading... abort */ + break; + } + + item = new GridItem(); + lastIndex = hash["path"].lastIndexOf('.'); if (lastIndex >= 0) @@ -3065,6 +3074,9 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) m_gridItems.append(item); loadImageDeferred(item, imagePath); + + if (i % 25 == 0) + qApp->processEvents(); } }