Bug 402082

Summary: Directly using `modelData` in combobox isn't safe
Product: [Frameworks and Libraries] frameworks-qqc2-desktop-style Reporter: Emmanuel Lepage Vallée <emmanuel.lepage>
Component: generalAssignee: Marco Martin <notmart>
Status: CONFIRMED ---    
Severity: normal CC: kde, nate
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Emmanuel Lepage Vallée 2018-12-13 08:55:23 UTC
modelData isn't always present. At least when I pass some totally fine models to the ComboBox, the content isn't visible when using qqc2-desktop-style and it is displayed in other themes.
Comment 1 David Edmundson 2018-12-13 10:48:23 UTC
The code does try to guard it:

org.kde.desktop/ComboBox.qml:        


text: controlRoot.textRole ? (Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] : model[controlRoot.textRole]) : modelData


code in QQC1 was:


                text: popup.textRole === '' ?
                        modelData :
                          ((popup.modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '')



@Emmanuel could you test if that works for your "totally fine model"
Comment 2 Emmanuel Lepage Vallée 2018-12-13 11:12:14 UTC
In my limited testing, this works

        text: controlRoot.textRole != undefined ? model[controlRoot.textRole] || "": (
            Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] :  modelData
        )