Skip to content

Commit

Permalink
fix(flightlog): fix crash when removing a flight log entry
Browse files Browse the repository at this point in the history
Should not modify an object while it is being iterated over..
  • Loading branch information
mwerle authored and impaktor committed Nov 30, 2024
1 parent aaa9cb7 commit 07a71a9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions data/pigui/modules/info-view/06-flightlog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ local function renderLog( formatter )
ui.separator()

local counter = 0
local entry_to_remove = nil
for entry in FlightLog:GetLogEntries(includedSet, nil, earliestFirst ) do
counter = counter + 1
local id = "##custom" .. counter
Expand All @@ -116,16 +117,19 @@ local function renderLog( formatter )

if entry:CanBeRemoved() then
if ui.iconButton("Remove" .. id, icons.trashcan, l.REMOVE) then
FlightLog:RemoveEntry( entry )
-- if we were already in edit mode, reset it, or else it carries over to next iteration
entering_text = false
entry_to_remove = entry
end
end

ui.nextColumn()
ui.separator()
ui.spacing()
end
if entry_to_remove then
FlightLog:RemoveEntry( entry_to_remove )
-- if we were already in edit mode, reset it, or else it carries over to next iteration
entering_text = false
end
end

local Windows = {
Expand Down

0 comments on commit 07a71a9

Please sign in to comment.