mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
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.
This commit is contained in:
1 parent
ecbce16c99
commit
d126e7f25a
1 file changed
+4
-2
@@ -2,9 +2,11 @@ local ensure_character = require("modules/inventory_sync/ensure_character")
|
|||||||
|
|
||||||
-- on_gui_click
|
-- on_gui_click
|
||||||
local handle_gui_events = function(event)
|
local handle_gui_events = function(event)
|
||||||
|
if not event.element.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
local element = event.element
|
if event.element.name == "inventory_sync_failed_download_abort" then
|
||||||
if element.name == "inventory_sync_failed_download_abort" then
|
|
||||||
-- Give the player a new inventory and mark it as dirty
|
-- Give the player a new inventory and mark it as dirty
|
||||||
-- Show dirty status and an explanation in a GUI
|
-- Show dirty status and an explanation in a GUI
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user