RonenNess / GeonBit.UI

UI system for MonoGame projects.
MIT License
478 stars 64 forks source link

dropdown and AutoSetListHeight #93

Closed SerialKicked closed 5 years ago

SerialKicked commented 6 years ago

I'm so sorry (but welcome to my life)

A bug that i noticed before, but were never able to reproduce in a consistent fashion. I had a way to avoid it entirely, but it's apparently not reliable, as i have users complaining about it now.

simply put, things like that:

      DropDown terraintype = new DropDown(new Vector2(0, 40), Anchor.Auto)
        {
            OnValueChange = (Entity entity) =>
            {
                World.MapSetup.TerrainType = ((DropDown)entity).SelectedValue;
            }
        };
        var id = 0;
        var nb = 0;
        foreach (var item in World.DB.TerrainPresets)
        {
            terraintype.AddItem(item.Key);
            if (item.Key.ToLower() == "mixed")
                id = nb;
            nb++;
        }
        terraintype.SelectedIndex = id;
        terraintype.AutoSetListHeight = true;
        LeftPanel.AddChild(terraintype);

can trigger a crash when the user click on the dropdown (can't reproduce but here's a trace https://pastebin.com/GVWKUfme ).

Setting the selectedindex after autosetlistheight can trigger a crash too, on rendering/update, but that i managed to avoid. I would love to be more precise, but it's definitely not consistent, or at least i haven't found what would make it consistent.

Might have something to do with me setting up the size vector, which is apparently for the underlying select list, and not the drop-down itself. I'm not sure, but any pointer would be super helpful.

Cheers.

RonenNess commented 6 years ago

Woha that's a serious bug, crashing the game is not cool at all. Not sure when I'll have time to dive into this (looks a bit tricky too), but may I suggest that until its solved wrap this call with try-catch and some default handling, so it won't crash your clients..

Ofc if you find any additional data let me know..

Thanks,

RonenNess commented 5 years ago

Fixed, currently in a branch, will be merged and released soon.

Thanks!

SerialKicked commented 5 years ago

Thank you! Sorry i couldn't get back to you earlier, I've been kept extremely busy these last few weeks.