AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.11k stars 127 forks source link

[bug] Labels keep getting corrupted with a ListBox and Table combo #804

Closed hhvn-uk closed 1 week ago

hhvn-uk commented 1 week ago

What happend?

I have a ListBox which contains a string for each element in an array.

I then have a table below which shows more information about the selected element.

After selecting a couple different elements, all the text seems to get corrupted like this: gui

But attaching dlv and looking at the function that builds the list.. it's all fine: dlv

Code example

The program I'm working on is a bit of a mess at the moment, so I've made a tarball that contains it in its current state and the input file I'm using.

To Reproduce

make
./gui library.json

Click a couple different items in the list

Version

(latest)

OS

Void Linux x86_64

hhvn-uk commented 1 week ago

I should clarify that with the dlv screenshot, I simply broke on the tostrings() function and then stepped thru it a bit before printing ret, hence the empty strings.

gucio321 commented 1 week ago

https://hhvn.uk/archive.tar.bz 404

unfortunately I can't say much without seeing your code..

hhvn-uk commented 1 week ago

Ah sorry my bad. I am way too scatterbrained.

https://hhvn.uk/gui.tar.bz

If that's not right you've got the right to demand I eat my hat :)

gucio321 commented 1 week ago

ok, first of all, you're using v0.7.0, which was the last release with imgui-go. Now we migrated to cimgui-go and technically can't support imgui-go anymore (@AllenDang maybe we should release v0.8.0 now as most things seems to work?) I've updated your project and now it crashes when clicking on 6th item:

File: /home/runner/work/cimgui-go/cimgui-go/cimgui/imgui/imgui_draw.cpp, Line 3307

Expression: Glyphs.Size > 0 && "Font has not loaded glyph!"

I have no idea why :smile:

AllenDang commented 1 week ago

@gucio321 Agree, let's release the 0.8.0. Maybe you could do it and write a release announcement to reddit? Because you are the major developer of this release, many thanks from the bottom of my heart for your contribution. So I'd like you to be the one to do it. What do you think?

gucio321 commented 1 week ago

@hhvn-uk I got it. consider what exactly does this line:

                KeyVal("Series #", string(sel.NSeries)),

It takes sel.NSeries (which is intager) and enforces go to interpret it as a string, which then is passed to cimgui-go. In case of 6th position in your library, NSeries = 0, so string(0) becomes a NULL character (ref: ascii table). and ofc our default font does not have it.

@gucio321 Agree, let's release the 0.8.0. Maybe you could do it and write a release announcement to reddit? Because you are the major developer of this release, many thanks from the bottom of my heart for your contribution. So I'd like you to be the one to do it. What do you think?

@allenDang, sure, I can make a release. thank you for your appreciation ;-)

gucio321 commented 1 week ago

@AllenDang you should see v0.8.0 - I made it draft for now, could you check if everything is ok, and publish/let me know?

AllenDang commented 1 week ago

@gucio321 Everything looks good, lets roll it out.

hhvn-uk commented 1 week ago

It takes sel.NSeries (which is intager) and enforces go to interpret it as a string, which then is passed to cimgui-go. In case of 6th position in your library, NSeries = 0, so string(0) becomes a NULL character (ref: ascii table). and ofc our default font does not have it.

Ah hah! I now see why strconv.Itoa exists.

Thanks. I could never have guessed that that caused it. Seems weird for one character to affect everything.