Bug 402082 - Directly using `modelData` in combobox isn't safe
Summary: Directly using `modelData` in combobox isn't safe
Status: CONFIRMED
Alias: None
Product: frameworks-qqc2-desktop-style
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-13 08:55 UTC by Emmanuel Lepage Vallée
Modified: 2019-01-16 00:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
        )