From fea05bb0dba069c82b9dbe2a71b31f88cf54a712 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 28 Feb 2017 19:51:52 +0100 Subject: Avoid "Unable to assign...." errors i.e. "Unable to assign [undefined] to Sink::ApplicationDomain::Folder::Ptr" Because qml does not know how to assign a default-constructed value we have to use conditional bindings. The !! operator checks for availability of the property which then triggers the binding. I assume an alternative viable approach would be to expose all controller properties as QVariants only, in which case an assignment from null would work (it doesn't for Folder::Ptr). --- components/package/contents/ui/FolderListView.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'components/package/contents/ui/FolderListView.qml') diff --git a/components/package/contents/ui/FolderListView.qml b/components/package/contents/ui/FolderListView.qml index 9ac73fb4..a4d25e02 100644 --- a/components/package/contents/ui/FolderListView.qml +++ b/components/package/contents/ui/FolderListView.qml @@ -28,14 +28,18 @@ import org.kube.framework.domain 1.0 as KubeFramework Rectangle { id: root - property variant currentFolder + property variant currentFolder: null property variant accountId color: Kirigami.Theme.textColor KubeFramework.FolderController { id: folderController - folder: root.currentFolder + Binding on folder { + //!! checks for the availability of the type + when: !!root.currentFolder + value: root.currentFolder + } } Menu { -- cgit v1.2.3