# HG changeset patch # User Edouard Tisserant # Date 1663079361 -7200 # Node ID f1a00aa8cb3b34881d5c282ec848b50ab49a1689 # Parent 1bd8e077894e5ad47cae310ec9f0e20492c899b9 SVGHMI: rework the way cached values are applied to widgets when fresh data is missing. diff -r 1bd8e077894e -r f1a00aa8cb3b svghmi/svghmi.js --- a/svghmi/svghmi.js Mon Sep 12 11:56:52 2022 +0200 +++ b/svghmi/svghmi.js Tue Sep 13 16:29:21 2022 +0200 @@ -1,7 +1,5 @@ // svghmi.js -var need_cache_apply = []; - function dispatch_value(index, value) { let widgets = subscribers(index); @@ -86,10 +84,6 @@ } } - while(widget = need_cache_apply.pop()){ - widget.apply_cache(); - } - if(jumps_need_update) update_jumps(); diff -r 1bd8e077894e -r f1a00aa8cb3b svghmi/widget_foreach.ysl2 --- a/svghmi/widget_foreach.ysl2 Mon Sep 12 11:56:52 2022 +0200 +++ b/svghmi/widget_foreach.ysl2 Tue Sep 13 16:29:21 2022 +0200 @@ -140,7 +140,7 @@ this.unsub_items(); this.sub_items(); update_subscriptions(); - need_cache_apply.push(this); + this.apply_cache(); jumps_need_update = true; requestHMIAnimation(); } diff -r 1bd8e077894e -r f1a00aa8cb3b svghmi/widgets_common.ysl2 --- a/svghmi/widgets_common.ysl2 Mon Sep 12 11:56:52 2022 +0200 +++ b/svghmi/widgets_common.ysl2 Tue Sep 13 16:29:21 2022 +0200 @@ -343,9 +343,7 @@ this.lastdispatch[i] = undefined; this.undeafen(i); } - let index = this.indexes[i]; - if(this.relativeness[i]) - index += this.offset; + let index = this.get_variable_index(i); subscribers(index).delete(this); } this.offset = 0; @@ -362,17 +360,17 @@ if(index == undefined) continue; subscribers(index).add(this); } - need_cache_apply.push(this); + this.apply_cache(); } apply_cache() { - for(let index in this.indexes){ + for(let i = 0; i < this.indexes_length; i++) { /* dispatch current cache in newly opened page widgets */ - let realindex = this.get_variable_index(index); + let realindex = this.get_variable_index(i); if(realindex == undefined) continue; let cached_val = cache[realindex]; if(cached_val != undefined) - this.feed_data_for_dispatch(cached_val, cached_val, index); + this.feed_data_for_dispatch(cached_val, cached_val, i); } }