From d126e7f25a6baf740244398c307f134d1d3567e9 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 10 Aug 2021 18:19:18 +0200 Subject: [PATCH] Validate GUI element in on_gui_click Make sure the GUI element in the on_gui_click event is valid before attempting to access this, as another module may have destroyed it during its event handler. --- plugins/inventory_sync/module/gui/handle_gui_events.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/inventory_sync/module/gui/handle_gui_events.lua b/plugins/inventory_sync/module/gui/handle_gui_events.lua index c2ed1dfb..5935c058 100644 --- a/plugins/inventory_sync/module/gui/handle_gui_events.lua +++ b/plugins/inventory_sync/module/gui/handle_gui_events.lua @@ -2,9 +2,11 @@ local ensure_character = require("modules/inventory_sync/ensure_character") -- on_gui_click local handle_gui_events = function(event) + if not event.element.valid then + return + end local player = game.get_player(event.player_index) - local element = event.element - if element.name == "inventory_sync_failed_download_abort" then + if event.element.name == "inventory_sync_failed_download_abort" then -- Give the player a new inventory and mark it as dirty -- Show dirty status and an explanation in a GUI