@@ -190,8 +190,9 @@ return function(Iris: Types.Iris): Types.Internal
190
190
end
191
191
192
192
for _ , widget : Types .Widget in Internal ._lastVDOM do
193
- if widget .lastCycleTick ~= Internal ._cycleTick then
193
+ if widget .lastCycleTick ~= Internal ._cycleTick and ( widget . lastCycleTick ~= - 1 ) then
194
194
-- a widget which used to be rendered was not called last frame, so we discard it.
195
+ -- if the cycle tick is -1 we have already discarded it.
195
196
Internal ._DiscardWidget (widget )
196
197
end
197
198
end
@@ -404,7 +405,6 @@ return function(Iris: Types.Iris): Types.Internal
404
405
find the previous frame widget if it exists. If no widget exists, a new one is created.
405
406
]=]
406
407
function Internal ._Insert (widgetType : string , args : Types.WidgetArguments ? , states : Types.WidgetStates ? ): Types .Widget
407
- local thisWidget : Types .Widget
408
408
local ID : Types .ID = Internal ._getID (3 )
409
409
-- debug.profilebegin(ID)
410
410
@@ -430,19 +430,19 @@ return function(Iris: Types.Iris): Types.Internal
430
430
-- prevents tampering with the arguments which are used to check for changes.
431
431
table .freeze (arguments )
432
432
433
- if Internal ._lastVDOM [ID ] and widgetType == Internal ._lastVDOM [ID ].type then
433
+ local lastWidget : Types .Widget ? = Internal ._lastVDOM [ID ]
434
+ if lastWidget and widgetType == lastWidget .type then
434
435
-- found a matching widget from last frame.
435
436
if Internal ._localRefreshActive then
436
437
-- we are redrawing every widget.
437
- Internal ._DiscardWidget (Internal ._lastVDOM [ID ])
438
- else
439
- thisWidget = Internal ._lastVDOM [ID ]
438
+ Internal ._DiscardWidget (lastWidget )
439
+ -- so we don't accidentally discard it twice
440
+ lastWidget .lastCycleTick = - 1
441
+ lastWidget = nil
440
442
end
441
443
end
442
- if thisWidget == nil then
443
- -- didnt find a match, generate a new widget.
444
- thisWidget = Internal ._GenNewWidget (widgetType , arguments , states , ID )
445
- end
444
+ local thisWidget : Types .Widget = if lastWidget == nil then Internal ._GenNewWidget (widgetType , arguments , states , ID ) else lastWidget
445
+
446
446
local parentWidget : Types .Widget = thisWidget .parentWidget
447
447
448
448
if thisWidget .type ~= " Window" and thisWidget .type ~= " Tooltip" then
0 commit comments