mirror of https://code.videolan.org/videolan/vlc
qml: improve initialization sequence in ExpandGridView
only set initialization flag after component is completed, try to avoid forceRelayout
This commit is contained in:
parent
d0fdb21e36
commit
c1e3248411
|
@ -177,7 +177,10 @@ FocusScope {
|
|||
|
||||
// Events
|
||||
|
||||
Component.onCompleted: flickable.layout(true)
|
||||
Component.onCompleted: {
|
||||
if (_initialize())
|
||||
flickable.layout(true)
|
||||
}
|
||||
|
||||
onHeightChanged: flickable.layout(false)
|
||||
|
||||
|
@ -493,15 +496,21 @@ FocusScope {
|
|||
|
||||
// Private
|
||||
|
||||
// returns true if this requires forceLayout
|
||||
function _initialize() {
|
||||
if (_isInitialised)
|
||||
return;
|
||||
|
||||
if (flickable.width === 0 || flickable.height === 0)
|
||||
return;
|
||||
if (currentIndex !== 0)
|
||||
positionViewAtIndex(currentIndex, ItemView.Contain)
|
||||
_isInitialised = true;
|
||||
if (flickable.width === 0 || flickable.height === 0)
|
||||
return false;
|
||||
|
||||
if (currentIndex !== 0) {
|
||||
positionViewAtIndex(currentIndex, ItemView.Contain)
|
||||
return false; // positionViewAtIndex will cause layout
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function _calculateCurrentRange() {
|
||||
|
@ -900,7 +909,7 @@ FocusScope {
|
|||
if (flickable.width === 0 || flickable.height === 0)
|
||||
return
|
||||
else if (!root._isInitialised)
|
||||
root._initialize()
|
||||
return
|
||||
|
||||
root.rowX = getItemPos(0)[0]
|
||||
|
||||
|
|
Loading…
Reference in New Issue