[vlc-commits] qml: don't positionViewAtIndex before view is loaded
Pierre Lamot
git at videolan.org
Thu Sep 10 16:10:31 CEST 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Sep 1 15:14:28 2020 +0200| [d3da0c142ee09bab1ac57cbd330624cea50dd385] | committer: Pierre Lamot
qml: don't positionViewAtIndex before view is loaded
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d3da0c142ee09bab1ac57cbd330624cea50dd385
---
modules/gui/qt/medialibrary/qml/MusicAlbums.qml | 3 ++-
modules/gui/qt/medialibrary/qml/MusicArtist.qml | 6 ++++--
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml | 6 ++++--
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml | 6 ++++--
modules/gui/qt/medialibrary/qml/MusicGenres.qml | 3 ++-
modules/gui/qt/medialibrary/qml/VideoDisplay.qml | 3 ++-
modules/gui/qt/network/qml/NetworkBrowseDisplay.qml | 6 ++++--
7 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 2a2bd81eb4..4f12c7cb1d 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -68,7 +68,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= albumModelId.count)
initialIndex = 0
selectionModel.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (view.currentItem)
+ view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
function _actionAtIndex(index) {
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtist.qml b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
index ac6762c9b0..9b91bd0fbc 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtist.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
@@ -181,8 +181,10 @@ Widgets.NavigableFocusScope {
initialIndex = 0
albumSelectionModel.select(albumModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
var albumsListView = medialib.gridView ? view.currentItem : headerItem.albumsListView
- albumsListView.currentIndex = initialIndex
- albumsListView.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (albumsListView) {
+ albumsListView.currentIndex = initialIndex
+ albumsListView.positionViewAtIndex(initialIndex, ItemView.Contain)
+ }
}
function _actionAtIndex(index, model, selectionModel) {
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
index 53a76fffa6..666819383f 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
@@ -52,8 +52,10 @@ Widgets.NavigableFocusScope {
initialIndex = 0
if (initialIndex !== artistList.currentIndex) {
selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- artistList.currentIndex = initialIndex
- artistList.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (artistList) {
+ artistList.currentIndex = initialIndex
+ artistList.positionViewAtIndex(initialIndex, ItemView.Contain)
+ }
}
}
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index c88facb7be..772af3f9f2 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -102,8 +102,10 @@ Widgets.NavigableFocusScope {
if (initialIndex >= artistModel.count)
initialIndex = 0
selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- view.currentItem.currentIndex = initialIndex
- view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (view.currentItem) {
+ view.currentItem.currentIndex = initialIndex
+ view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ }
}
MLArtistModel {
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
index eeeebb4e69..0bf1ce0d21 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
@@ -67,7 +67,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= genreModel.count)
initialIndex = 0
selectionModel.select(genreModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (view.currentItem)
+ view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
Connections {
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
index 867897b719..0318b80210 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
@@ -58,7 +58,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= videoModel.count)
initialIndex = 0
selectionModel.select(videoModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (view.currentItem)
+ view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
function _actionAtIndex(index) {
diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index 87edded22d..3a730f2476 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -54,8 +54,10 @@ Widgets.NavigableFocusScope {
if (initialIndex >= providerModel.count)
initialIndex = 0
selectionModel.select(providerModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- view.currentItem.currentIndex = initialIndex
- view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ if (view.currentItem) {
+ view.currentItem.currentIndex = initialIndex
+ view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+ }
}
More information about the vlc-commits
mailing list