Ticket #126 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Editor won't start; "This Widget is already attached to the User Interface"

Reported by: rikus Owned by: knowknowledge
Priority: minor Milestone:
Component: UI Version:
Keywords: Cc:

Description

Here is what happens:

bool Simulation::SetupToEdit() (Info) - Simulation Edit Setup Complete
bool Simulation::Edit() (Info) - Simulation Edit Starting
virtual Container* Container::AddChild(Widget*) (Info) - Adding Button Alliance 0x80fb87470 to Master
virtual bool Container::IsAttached(Widget*) (Info) - Found Button Alliance (0x80fb87470) in Master
static int Lua::ErrorCatch(lua_State*) (Error) - Fatal Error in Lua 'error running function `componentDebugger': Resources/Scripts/editor.lua:7: bad argument #2 to 'add' (This Widget is already attached to the User Interface.)'
Assertion failed: (0), function ErrorCatch, file Source/Utilities/lua.cpp, line 208.
zsh: abort      ./epiar

And I noticed that this patch to add widgets individually rather than all at once will work around whatever the problem is:

diff --git a/Resources/Scripts/editor.lua b/Resources/Scripts/editor.lua
index b47a25f..17738e7 100644
--- a/Resources/Scripts/editor.lua
+++ b/Resources/Scripts/editor.lua
@@ -4,7 +4,7 @@ componentWins = {}
 
 --- View components
 function componentDebugger()
-	UI.add(
+	for num,button in pairs {
 		UI.newButton(  0,0,100,30,"Alliance","componentViewer('Alliance',Epiar.alliances,'Epiar.getAllianceInfo')" ),
 		UI.newButton(100,0,100,30,"Commodity","componentViewer('Commodity',Epiar.commodities,'Epiar.getCommodityInfo')" ),
 		UI.newButton(200,0,100,30,"Engine","componentViewer('Engine',Epiar.engines,'Epiar.getEngineInfo')" ),
@@ -14,8 +14,8 @@ function componentDebugger()
 		UI.newButton(600,0,100,30,"Technology","technologyViewer()"),
 		UI.newButton(700,0,100,30,"Weapon","componentViewer('Weapon',Epiar.weapons,'Epiar.getWeaponInfo')" ),
 		UI.newButton(800,0,100,30,"Outfit","componentViewer('Outfit',Epiar.outfits,'Epiar.getOutfitInfo')" ),
-    	UI.newButton(WIDTH/2-50, HEIGHT-30, 100, 30, "Save Components", "Epiar.saveComponents()" )
-	)
+		UI.newButton(WIDTH/2-50, HEIGHT-30, 100, 30, "Save Components", "Epiar.saveComponents()" )
+	} do UI.add(button) end
 end
 
 --- The EditorLayouts describe the ordering and type of the component attributes

Change History

comment:1 Changed 2 years ago by knowknowledge

  • Owner set to knowknowledge
  • Status changed from new to assigned

It looks like this is a typo in the addWidget Function (the method works), where only the widget was being added to the UI over and over.

-		Widget* widget = checkWidget(L,1);
+		Widget* widget = checkWidget(L,i);

I'll push a fix ASAP.

comment:2 Changed 2 years ago by knowknowledge

  • Status changed from assigned to closed
  • Resolution set to fixed

The fix has been pushed.

Note: See TracTickets for help on using tickets.