From 1e5b032cff2d3de21612db60ebdd80b795610b8e Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 14 Sep 2017 15:55:35 +0200 Subject: [PATCH] Make canvas use a one-time Timer to update CURA-4182 The canvas approach has a drawback on the UI update: when a printcore or a material is changed, calling requestPaint() to the canvas doesn't trigger an immediate update. The solution is to have a built-in Timer in the Canvas and to use that to update. Somehow this just works. The problem with this approach is that the Timer constantly updates the canvas which eats a lot of CPU power. To solve this, I changed the timer to be a one-time timer and it will be started when there is a material/print core update. --- resources/qml/SidebarSimple.qml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 20d92885d7..bbfd8a424a 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -143,6 +143,7 @@ Item } } resolutionSlider.currentQualityIndex = undefined; + backgroundBarUpdateTimer.start(); } function updateBar() @@ -246,9 +247,10 @@ Item anchors.fill: parent Timer { - interval: 16 - running: true - repeat: true + id: backgroundBarUpdateTimer + interval: 10 + running: false + repeat: false onTriggered: backgroundBar.requestPaint() }