Ver Fonte

Improved error handling for page component loading.

Malte Veerman há 5 anos atrás
pai
commit
12c5e7eea3
1 ficheiros alterados com 22 adições e 3 exclusões
  1. 22 3
      fancontrol-gui/package/contents/ui/Application.qml

+ 22 - 3
fancontrol-gui/package/contents/ui/Application.qml

@@ -47,8 +47,22 @@ Kirigami.ApplicationWindow {
 
     onLeftPageChanged: {
         window.pageStack.clear();
-        if (leftPage)
-            window.pageStack.push(Qt.resolvedUrl(leftPage));
+        if (leftPage) {
+            var url = Qt.resolvedUrl(leftPage);
+            var component = Qt.createComponent(url);
+
+            if (component.status == Component.Ready) {
+                var page = component.createObject(window.pageStack);
+
+                if (page)
+                    window.pageStack.push(page);
+                else
+                    console.log("Error creating page object: %1", url);
+            } else {
+                console.log("Error creating page component: %1", component.errorString());
+            }
+
+        }
     }
 
     onWideScreenChanged: drawer.drawerOpen = wideScreen
@@ -79,10 +93,15 @@ Kirigami.ApplicationWindow {
             for (var i=fansAction.children.length-1; i>=0; i--) {
                 fansAction.children[i].destroy();
             }
+
             var actions = [];
             for (var i=0; i<20; i++) {
                 var action = fanActionComponent.createObject(fansAction, { "index": i });
-                actions.push(action);
+
+                if (action)
+                    actions.push(action);
+                else
+                    console.log("Error creating fan action with index %1", i);
             }
             fansAction.children = actions;
         }