From 1a34c7f18f54d2b5397dad247cc2c08674322a93 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 10 Sep 2015 16:43:14 +0200 Subject: Manage the case when __style doesn't exist yet at onCompleted since __style gets instantiated by a loader, we are not sure that when Component.onCompleted is triggered, __style will be already there. manage separately the case when __style will be instantiated right after the component is complete. Change-Id: I23418138881904b10741159835e7f825363bc022 Reviewed-by: Richard Moe Gustavsen --- src/controls/Private/EditMenu.qml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/controls/Private/EditMenu.qml') diff --git a/src/controls/Private/EditMenu.qml b/src/controls/Private/EditMenu.qml index dc3ba64a..a70e8407 100644 --- a/src/controls/Private/EditMenu.qml +++ b/src/controls/Private/EditMenu.qml @@ -47,6 +47,7 @@ Loader { property Component defaultMenu: item && item.defaultMenu ? item.defaultMenu : null property QtObject menuInstance: null property MouseArea mouseArea + property QtObject style: __style Connections { target: control @@ -67,13 +68,18 @@ Loader { return menuInstance; } - Component.onCompleted: { - if (__style.__editMenu) { - sourceComponent = __style.__editMenu; - } else { + function syncStyle() { + if (!style) + return; + + if (style.__editMenu) + sourceComponent = style.__editMenu; + else { // todo: get ios/android/base menus from style as well source = (Qt.resolvedUrl(Qt.platform.os === "ios" ? "EditMenu_ios.qml" : Qt.platform.os === "android" ? "" : "EditMenu_base.qml")); } } + onStyleChanged: syncStyle(); + Component.onCompleted: syncStyle(); } -- cgit v1.2.1