[vlc-commits] qml: fix undefined reference when model is undefined in DNDLabel

Pierre Lamot git at videolan.org
Thu Sep 10 16:10:26 CEST 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Aug 28 10:18:29 2020 +0200| [b91999aa9556fdf0f3be5a5b23ced098783585b5] | committer: Pierre Lamot

qml: fix undefined reference when model is undefined in DNDLabel

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b91999aa9556fdf0f3be5a5b23ced098783585b5
---

 modules/gui/qt/widgets/qml/DNDLabel.qml | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/DNDLabel.qml b/modules/gui/qt/widgets/qml/DNDLabel.qml
index 48b7b3167a..39a189faf3 100644
--- a/modules/gui/qt/widgets/qml/DNDLabel.qml
+++ b/modules/gui/qt/widgets/qml/DNDLabel.qml
@@ -19,6 +19,7 @@ import QtQuick 2.11
 import QtQuick.Controls 2.4
 import QtQuick.Layouts 1.3
 import QtGraphicalEffects 1.0
+import org.videolan.vlc 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
@@ -89,14 +90,14 @@ Rectangle {
                     id: artwork
                     anchors.fill: parent
                     fillMode: Image.PreserveAspectFit
-                    source: (model.artwork && model.artwork.toString()) ? model.artwork : VLCStyle.noArtCover
+                    source: (model && model.artwork && model.artwork.toString()) ? model.artwork : VLCStyle.noArtCover
                     visible: !statusIcon.visible
                 }
 
                 Widgets.IconLabel {
                     id: statusIcon
                     anchors.fill: parent
-                    visible: (model.isCurrent && text !== "")
+                    visible: (!!model && model.isCurrent && text !== "")
                     width: height
                     height: VLCStyle.icon_normal
                     horizontalAlignment: Text.AlignHCenter
@@ -113,8 +114,8 @@ Rectangle {
                     id: textInfo
                     Layout.leftMargin: VLCStyle.margin_small
 
-                    font.weight: model.isCurrent ? Font.DemiBold : Font.Normal
-                    text: model.title
+                    font.weight: model && model.isCurrent ? Font.DemiBold : Font.Normal
+                    text: model ? model.title : ""
                     color: _colors.text
                 }
 
@@ -122,8 +123,8 @@ Rectangle {
                     id: textArtist
                     Layout.leftMargin: VLCStyle.margin_small
 
-                    font.weight: model.isCurrent ? Font.DemiBold : Font.Normal
-                    text: (model.artist ? model.artist : i18n.qtr("Unknown Artist"))
+                    font.weight: (model && model.isCurrent) ? Font.DemiBold : Font.Normal
+                    text: ((model && model.artist) ? model.artist : i18n.qtr("Unknown Artist"))
                     color: _colors.text
                 }
             }
@@ -132,7 +133,7 @@ Rectangle {
                 id: textDuration
                 Layout.rightMargin: VLCStyle.margin_xsmall
 
-                text: model.duration
+                text: model ? model.duration : ""
                 color: _colors.text
             }
         }



More information about the vlc-commits mailing list