[2.0.45] on_gui_opened and on_gui_closed events fire in incorrect order

Bugs that are actually features.
Osmo
Inserter
Inserter
Posts: 48
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

[2.0.45] on_gui_opened and on_gui_closed events fire in incorrect order

Post by Osmo »

This issue happens with the mod Remote view item transfer(RVIT) and some mods that add to or replace entity GUIs.
In this report i will use Project Cybersyn(CS) as a mod that adds guis as i have not been able to replicate this issue with a trivial example.

To reproduce the issue:
1. Load the save file
gui-dupe2.zip
(137 KiB) Downloaded 10 times
2. Open remote view and open the Cybernetic combinator
3. Following error occures: "Gui element with name cybersyn-combinator already present in the parent element."

The relevant information about RVIT is that whenever any entity is opened in remote view (and the player is within reach), it changes the player's controller, thereby closing the gui, and then reopens the said entity.

For illustration purposes, i've added a print statement at the very beginning of each respective event's function
изображение.png
изображение.png (60.58 KiB) Viewed 137 times
As you can see, the first "opened" event fires only for RVIT, while CS has an extra "opened" event at the end
Attachments
factorio-current.log
(9.84 KiB) Downloaded 6 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 15583
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.45] on_gui_opened and on_gui_closed events fire in incorrect order

Post by Rseding91 »

Thanks for the report however, they are. The mod code is faulty and the following is happening:

on_gui_opened happens -> the mod closes the GUI -> on_gui_closed is called -> the mod opens a GUI -> on_gui_opened happens

Except the first on_gui_opened mod code is not finished from the first entry point yet and it runs into the error.
If you want to get ahold of me I'm almost always on Discord.
Osmo
Inserter
Inserter
Posts: 48
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: [2.0.45] on_gui_opened and on_gui_closed events fire in incorrect order

Post by Osmo »

Thank you for explaining it, it was very non obvious why it was happening
Post Reply

Return to “Not a bug”