diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-23 10:44:08 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-23 13:23:51 +0000 |
commit | c59c43bbc44026a508746b1de2505f6185bd0310 (patch) | |
tree | 7d2be9445206f8107382c1c692bd20c994a23a16 /tests | |
parent | 18624d2d4602e5ac6466ee815a9c34bbf6061de1 (diff) |
ComboBox: fix usage in an asynchronous Loader
The following comment in QQmlDelegateModel::object() helped to find
a solution ie. using createdItem() instead of initItem():
If asynchronous is true or the component is being loaded asynchronously due
to an ancestor being loaded asynchronously, item() may return 0. In this
case createdItem() will be emitted when the item is available. [...]
Change-Id: If3bf8e60834534ca07c8db8f502f4f11969057e8
Task-number: QTBUG-51972
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 759a1ebc..0a2c3101 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -756,4 +756,29 @@ TestCase { control.destroy() } + + Component { + id: asyncLoader + Loader { + active: false + asynchronous: true + sourceComponent: ComboBox { + model: ["First", "Second", "Third"] + } + } + } + + // QTBUG-51972 + function test_async() { + var loader = asyncLoader.createObject(testCase) + verify(loader) + + loader.active = true + tryCompare(loader, "status", Loader.Ready) + verify(loader.item) + compare(loader.item.currentText, "First") + compare(loader.item.displayText, "First") + + loader.destroy() + } } |