[vlc-devel] [PATCH 6/7] qml: fix reference error in language menu control

Fatih Uzunoglu fuzun54 at outlook.com
Sun Apr 11 21:45:31 UTC 2021


fixes qml errors that happens when the toolbar editor
gets opened.

Intends to be a temporary solution for #25643.
---
 modules/gui/qt/player/qml/ControlButtons.qml | 43 ++++++++++++--------
 modules/gui/qt/player/qml/LanguageMenu.qml   |  2 +-
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/modules/gui/qt/player/qml/ControlButtons.qml b/modules/gui/qt/player/qml/ControlButtons.qml
index 79cbc0900d..cc788591a4 100644
--- a/modules/gui/qt/player/qml/ControlButtons.qml
+++ b/modules/gui/qt/player/qml/ControlButtons.qml
@@ -436,30 +436,37 @@ Item{
             size: VLCStyle.icon_medium
             iconText: VLCIcons.audiosub
 
-            onClicked: langMenu.open()
+            enabled: langMenuLoader.status === Loader.Ready
+            onClicked: langMenuLoader.item.open()
 
             text: i18n.qtr("Languages and tracks")
 
-            LanguageMenu {
-                id: langMenu
+            Loader {
+                id: langMenuLoader
 
-                parent: rootPlayer
-                focus: true
-                x: 0
-                y: (!!rootPlayer) ? (rootPlayer.positionSliderY - height) : 0
-                z: 1
+                active: (typeof rootPlayer !== 'undefined') && (rootPlayer !== null)
 
-                onOpened: {
-                    controlButtons.requestLockUnlockAutoHide(true, controlButtons)
-                    if (!!rootPlayer)
-                        rootPlayer.menu = langMenu
-                }
+                sourceComponent: LanguageMenu {
+                    id: langMenu
 
-                onClosed: {
-                    controlButtons.requestLockUnlockAutoHide(false, controlButtons)
-                    langBtn.forceActiveFocus()
-                    if (!!rootPlayer)
-                        rootPlayer.menu = undefined
+                    parent: rootPlayer
+                    focus: true
+                    x: 0
+                    y: (rootPlayer.positionSliderY - height)
+                    z: 1
+
+                    onOpened: {
+                        controlButtons.requestLockUnlockAutoHide(true, controlButtons)
+                        if (!!rootPlayer)
+                            rootPlayer.menu = langMenu
+                    }
+
+                    onClosed: {
+                        controlButtons.requestLockUnlockAutoHide(false, controlButtons)
+                        langBtn.forceActiveFocus()
+                        if (!!rootPlayer)
+                            rootPlayer.menu = undefined
+                    }
                 }
             }
         }
diff --git a/modules/gui/qt/player/qml/LanguageMenu.qml b/modules/gui/qt/player/qml/LanguageMenu.qml
index 930fbef8f5..51cdc50bd2 100644
--- a/modules/gui/qt/player/qml/LanguageMenu.qml
+++ b/modules/gui/qt/player/qml/LanguageMenu.qml
@@ -33,7 +33,7 @@ T.Popup {
     id: control
 
     height: VLCStyle.dp(296, VLCStyle.scale)
-    width: (!!rootPlayer) ? rootPlayer.width : 0
+    width: rootPlayer.width
 
     // Popup.CloseOnPressOutside doesn't work with non-model Popup on Qt < 5.15
     closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
-- 
2.27.0



More information about the vlc-devel mailing list