Page 1 of 1

[2.0.45] on_gui_opened and on_gui_closed events fire in incorrect order

Posted: Thu Apr 24, 2025 2:32 pm
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 138 times
As you can see, the first "opened" event fires only for RVIT, while CS has an extra "opened" event at the end

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

Posted: Thu Apr 24, 2025 4:40 pm
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.

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

Posted: Thu Apr 24, 2025 5:07 pm
by Osmo
Thank you for explaining it, it was very non obvious why it was happening