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/mail/contents/ui/Mail.qml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'components/mail/contents/ui') diff --git a/components/mail/contents/ui/Mail.qml b/components/mail/contents/ui/Mail.qml index b88e846d..c400d8f3 100644 --- a/components/mail/contents/ui/Mail.qml +++ b/components/mail/contents/ui/Mail.qml @@ -84,12 +84,20 @@ Controls2.ApplicationWindow { //Controller KubeFramework.MailController { id: mailController - threadLeader: mailListView.currentMail + Binding on threadLeader { + //!! checks for the availability of the type + when: !!mailListView.currentMail + value: mailListView.currentMail + } } KubeFramework.FolderController { id: folderController - folder: folderListView.currentFolder + Binding on folder { + //!! checks for the availability of the type + when: !!folderListView.currentFolder + value: folderListView.currentFolder + } } //BEGIN Shortcuts -- cgit v1.2.3