Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug FontGlyphRangesBuilder #206

Closed
Wolf65 opened this issue Sep 11, 2023 · 39 comments · Fixed by #208 or #229
Closed

Bug FontGlyphRangesBuilder #206

Wolf65 opened this issue Sep 11, 2023 · 39 comments · Fixed by #208 or #229
Labels
bug Something isn't working investigating Searching for origins of the issue.

Comments

@Wolf65
Copy link

Wolf65 commented Sep 11, 2023

last PR

working option

io.Fonts().AddFontFromFileTTFV("fonts/ttf/JetBrainsMono-Medium.ttf",
	baseFontSize,
	&baseConfig,
	imgui.CurrentIO().Fonts().GlyphRangesCyrillic())

when using NewGlyphRange/NewFontGlyphRangesBuilder

baseRange := imgui.NewGlyphRange()
baseBuilder := imgui.NewFontGlyphRangesBuilder()
baseBuilder.AddRanges(io.Fonts().GlyphRangesCyrillic())
baseBuilder.BuildRanges(baseRange)

io.Fonts().AddFontFromFileTTFV("fonts/ttf/JetBrainsMono-Medium.ttf",
	baseFontSize,
	&baseConfig,
baseRange.Data())

error

panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges.func1(0xc0000afe01?, 0xc0000afe70?)
        S:/goProject/cimgui-go/type_accessor.go:98 +0x34
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges({{0x2a958c4df90?, 0x7ff682e44a0a?, 0x2a958d52eb0?}}, 0xc0000afed0?)
        S:/goProject/cimgui-go/type_accessor.go:98 +0x48
poehelper/fonts.AppendDefaultFont(0x2a958d4a9a8?)
        S:/goProject/PoEHelper/fonts/Font.go:44 +0x8e
main.main()
        S:/goProject/PoEHelper/main.go:79 +0x21f
exit status 2
make: *** [Makefile:9: run] Error 1
@gucio321
Copy link
Collaborator

related to #184 as well as with #90. Need to wait for GO PR to fix this.

@gucio321 gucio321 added bug Something isn't working frozen can't make any progress here, because of independent on us reasons labels Sep 11, 2023
@gucio321
Copy link
Collaborator

Just to explain: mentioned code comes from utils.go so it isn't auto-generated, ergo #198 didn't apply to them

@gucio321
Copy link
Collaborator

well, It looks like something else...
Its about Vector[*uint32] need to investigate

@gucio321 gucio321 added investigating Searching for origins of the issue. and removed frozen can't make any progress here, because of independent on us reasons labels Sep 11, 2023
@gucio321
Copy link
Collaborator

After looking at dlv output I still suppose that it is caused by lack of runtime.Pinner in our code. Need to wait for GO PR.

@gucio321
Copy link
Collaborator

@Wolf65 patch #208 should fix this, however I need to do something around go version so gonna merge it tomorrow

@gucio321 gucio321 linked a pull request Sep 12, 2023 that will close this issue
@Wolf65
Copy link
Author

Wolf65 commented Sep 13, 2023

on go 1.21.1

Exception 0xc0000005 0x0 0xc0001c8000 0x7ff7fcc4ec10
PC=0x7ff7fcc4ec10
signal arrived during external code execution

runtime.cgocall(0x7ff7fcb915b0, 0xc000139db8)
        C:/Program Files/Go/src/runtime/cgocall.go:157 +0x3e fp=0xc000139d90 sp=0xc000139d58 pc=0x7ff7fc8c545e
github.com/AllenDang/cimgui-go._Cfunc_ImFontGlyphRangesBuilder_BuildRanges(0xc00010a760, 0x23c4601f9b0)
        _cgo_gotypes.go:5430 +0x4d fp=0xc000139db8 sp=0xc000139d90 pc=0x7ff7fc9aa06d
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges.func1(0x7ff7fc9aed46?, 0x7ff7fd2d6d00?)
        S:/goProject/cimgui-go/type_accessor.go:98 +0x5d fp=0xc000139df8 sp=0xc000139db8 pc=0x7ff7fc9b3d5d
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges({{0x23c4601f9b0?, 0x7ff7fc8c545e?, 0x23c7158adb0?, 0xc00010c110?}}, 0x7ff7fc8c5505?)
        S:/goProject/cimgui-go/type_accessor.go:98 +0x45 fp=0xc000139e40 sp=0xc000139df8 pc=0x7ff7fc9b3c85
poehelper/fonts.AppendDefaultFont(0x23c71582658?)
        S:/goProject/PoEHelper/fonts/Font.go:44 +0xb0 fp=0xc000139ec8 sp=0xc000139e40 pc=0x7ff7fca17e10
main.main()
        S:/goProject/PoEHelper/main.go:80 +0x23f fp=0xc000139f40 sp=0xc000139ec8 pc=0x7ff7fcb546bf
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:267 +0x2b2 fp=0xc000139fe0 sp=0xc000139f40 pc=0x7ff7fc8fbbd2
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc000139fe8 sp=0xc000139fe0 pc=0x7ff7fc928e61

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00006bfa8 sp=0xc00006bf88 pc=0x7ff7fc8fbfee
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:322 +0xb8 fp=0xc00006bfe0 sp=0xc00006bfa8 pc=0x7ff7fc8fbe78
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00006bfe8 sp=0xc00006bfe0 pc=0x7ff7fc928e61
created by runtime.init.6 in goroutine 1
        C:/Program Files/Go/src/runtime/proc.go:310 +0x1a

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00006df78 sp=0xc00006df58 pc=0x7ff7fc8fbfee
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.bgsweep(0x0?)
        C:/Program Files/Go/src/runtime/mgcsweep.go:280 +0x94 fp=0xc00006dfc8 sp=0xc00006df78 pc=0x7ff7fc8e5934
runtime.gcenable.func1()
        C:/Program Files/Go/src/runtime/mgc.go:200 +0x25 fp=0xc00006dfe0 sp=0xc00006dfc8 pc=0x7ff7fc8daca5
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00006dfe8 sp=0xc00006dfe0 pc=0x7ff7fc928e61
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:200 +0x66

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000012150?, 0x7ff7fd07d238?, 0x1?, 0x0?, 0xc000068b60?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00007df70 sp=0xc00007df50 pc=0x7ff7fc8fbfee
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.(*scavengerState).park(0x7ff7fd2d6540)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc00007dfa0 sp=0xc00007df70 pc=0x7ff7fc8e31e9
runtime.bgscavenge(0x0?)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc00007dfc8 sp=0xc00007dfa0 pc=0x7ff7fc8e377c
runtime.gcenable.func2()
        C:/Program Files/Go/src/runtime/mgc.go:201 +0x25 fp=0xc00007dfe0 sp=0xc00007dfc8 pc=0x7ff7fc8dac45
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00007dfe8 sp=0xc00007dfe0 pc=0x7ff7fc928e61
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:201 +0xa5

goroutine 18 [finalizer wait]:
runtime.gopark(0x7ff7fcfef260?, 0x1fc8fcf01?, 0x0?, 0x0?, 0x7ff7fc904365?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00006fe28 sp=0xc00006fe08 pc=0x7ff7fc8fbfee
runtime.runfinq()
        C:/Program Files/Go/src/runtime/mfinal.go:193 +0x107 fp=0xc00006ffe0 sp=0xc00006fe28 pc=0x7ff7fc8d9d67
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00006ffe8 sp=0xc00006ffe0 pc=0x7ff7fc928e61
created by runtime.createfing in goroutine 1
        C:/Program Files/Go/src/runtime/mfinal.go:163 +0x3d
rax     0x6d3
rbx     0xda60
rcx     0x1
rdi     0x23c4601f9b0
rsi     0xc00010a760
rbp     0x1
rsp     0xd3539ff780
r8      0xa681
r9      0xc0001c64b4
r10     0x7
r11     0x6
r12     0x23c6f0275f0
r13     0xa67f
r14     0x1
r15     0x0
rip     0x7ff7fcc4ec10
rflags  0x10216
cs      0x33
fs      0x53
gs      0x2b
exit status 2
make: *** [Makefile:9: run] Error 1

@gucio321
Copy link
Collaborator

Huh? It's strange...

@gucio321 gucio321 reopened this Sep 13, 2023
@gucio321
Copy link
Collaborator

@Wolf65 could you post some testing code? I checked on current giu migration pr and it worked

@Wolf65
Copy link
Author

Wolf65 commented Sep 13, 2023

https://github.com/Wolf65/Bug

While I was building the example, another commit was released and the error changed and another one appeared. I hope I explained it clearly in the main comments.

@gucio321
Copy link
Collaborator

I hope I explained it clearly in the main comments.

I was to lazy to construct my own code if I know that you have one for sure 😄 Sorry ;-)

In case of your bug...
I dont know why it doesn't work on windows... On linux I'm getting (instead of your panic) the following, clear output:

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

so

        IM_ASSERT_USER_ERROR(0, "Could not load font file!");

so the following makes it working for me

diff --git a/main.go b/main.go
index 91d760b..61f00a5 100644
--- a/main.go
+++ b/main.go
@@ -25,13 +25,13 @@ func main() {
 	baseBuilder.AddRanges(io.Fonts().GlyphRangesCyrillic())
 	baseBuilder.BuildRanges(baseRange)
 
-	io.Fonts().AddFontFromFileTTFV("fonts/ttf/JetBrainsMono-Medium.ttf",
+	io.Fonts().AddFontFromFileTTFV("JetBrainsMono-Medium.ttf",
 		baseFontSize,
 		&baseConfig,
 		baseRange.Data())

@Wolf65
Copy link
Author

Wolf65 commented Sep 13, 2023

About the path to the font. since it's a piece of code from the main project, I forgot to fix the path to the font. Sorry.

About the fall with panic. It may have fixed itself. I couldn't get it to repeat itself.

What about the code that's commented out below?
Which crashes with
main.go:49:3: cannot use imgui.SliceToPtr(IconRange) (value of type *uint16) as *imgui.Wchar value in argument to io.Fonts().AddFontFromFileTTFV

@gucio321
Copy link
Collaborator

//IconRange := []uint16{uint16(IconsFontAwesome6.Min), uint16(IconsFontAwesome6.Max16), 0}
This should be list of Wchars (which is uint32 probably)

@gucio321
Copy link
Collaborator

@Wolf65

diff --git a/main.go b/main.go
index 91d760b..f44f95c 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,8 @@
 package main
 
 import (
+	"fmt"
+
 	imgui "github.com/AllenDang/cimgui-go"
 )
 
@@ -25,13 +27,13 @@ func main() {
 	baseBuilder.AddRanges(io.Fonts().GlyphRangesCyrillic())
 	baseBuilder.BuildRanges(baseRange)
 
-	io.Fonts().AddFontFromFileTTFV("fonts/ttf/JetBrainsMono-Medium.ttf",
+	io.Fonts().AddFontFromFileTTFV("JetBrainsMono-Medium.ttf",
 		baseFontSize,
 		&baseConfig,
 		baseRange.Data())
 
-	//File: D:/a/cimgui-go/cimgui-go/cimgui/imgui/imgui_draw.cpp, Line: 2208
-	//exit status 1
+	// File: D:/a/cimgui-go/cimgui-go/cimgui/imgui/imgui_draw.cpp, Line: 2208
+	// exit status 1
 
 	// FontAwesome
 	fontAwesomeConfig := *imgui.NewFontConfig()
@@ -42,12 +44,12 @@ func main() {
 	fontAwesomeConfig.SetGlyphOffset(imgui.Vec2{X: 0, Y: 2})
 
 	////Whoa, I caught a bug while I was doing the test. If you uncomment the code below
-	//IconRange := []uint16{uint16(IconsFontAwesome6.Min), uint16(IconsFontAwesome6.Max16), 0}
-	//io.Fonts().AddFontFromFileTTFV(fmt.Sprintf("fonts/ttf/%s",
-	//	IconsFontAwesome6.Filenames[1][1]),
-	//	fontAwesomeFontSize,
-	//	&fontAwesomeConfig,
-	//	imgui.SliceToPtr(IconRange))
+	IconRange := []imgui.Wchar{imgui.Wchar(IconsFontAwesome6.Min), imgui.Wchar(IconsFontAwesome6.Max16), 0}
+	io.Fonts().AddFontFromFileTTFV(fmt.Sprintf("%s",
+		IconsFontAwesome6.Filenames[1][1]),
+		fontAwesomeFontSize,
+		&fontAwesomeConfig,
+		imgui.SliceToPtr(IconRange))
 	////.\main.go:49:3: cannot use imgui.SliceToPtr(IconRange) (value of type *uint16) as *imgui.Wchar value in argument to io.Fonts().AddFontFromFileTTFV
 
 	backend.Run(loop)

@Wolf65
Copy link
Author

Wolf65 commented Sep 14, 2023

@gucio321 I don't know how to comment on that.

bug.mp4

@gucio321
Copy link
Collaborator

@Wolf65 I need to run this code on my machine since it seems that my debugger is broken on windows.
Could you give some reproduction code? I managed to make Bug code working with the diff mentioned above

@Wolf65
Copy link
Author

Wolf65 commented Sep 14, 2023

It's a major project
https://github.com/Wolf65/PoEHelper

And in go.mod delete replace
Run "make"

@gucio321
Copy link
Collaborator

@Wolf65 it works for me???
image

@Wolf65
Copy link
Author

Wolf65 commented Sep 14, 2023

Yes and 2 imgui no merge windows

@gucio321
Copy link
Collaborator

windows are there, but I did something stupid and they disappeard
image

@gucio321
Copy link
Collaborator

But I can't reproduce ur panic 😕 Should I do something special?

@gucio321
Copy link
Collaborator

oh no, I've just watched ur vide again... Does this panic appear randomly????

@Wolf65
Copy link
Author

Wolf65 commented Sep 14, 2023

Uh, no. Like in the video ~3 starts up ~3 times then ~6 panics.

@gucio321
Copy link
Collaborator

could you try gdb on it? (you need specificly gdb, because dlv couldn't talk with C (or I can't make it talk with c))

@gucio321 gucio321 reopened this Sep 14, 2023
@gucio321 gucio321 changed the title Bug FontGlyphRangesBuilder (cgo argument has Go pointer to Go pointer) Bug FontGlyphRangesBuilder Sep 14, 2023
@Wolf65
Copy link
Author

Wolf65 commented Sep 15, 2023

(gdb) run
Starting program: /s/goProject/PoEHelper/_out/PoEHelperDebug.exe
[New Thread 15092.0x17a8]
[New Thread 15092.0x37bc]
[New Thread 15092.0x928]
[New Thread 15092.0x4c78]
[New Thread 15092.0x24a4]
[New Thread 15092.0x60c0]
[New Thread 15092.0x30cc]
[New Thread 15092.0x5168]
DEBUG  [2023-09-15 18:30:00] init map lab
DEBUG  [2023-09-15 18:30:00] register map lab pages
DEBUG  [2023-09-15 18:30:00] init settings
DEBUG  [2023-09-15 18:30:00] register setting pages
DEBUG  [2023-09-15 18:30:00] init trade
DEBUG  [2023-09-15 18:30:00] register trade pages
DEBUG  [2023-09-15 18:30:00] .exe path: S:\goProject\PoEHelper\_out
DEBUG  [2023-09-15 18:30:00] Font folder exists
DEBUG  [2023-09-15 18:30:00] JetBrainsMono-Medium.ttf exists
DEBUG  [2023-09-15 18:30:00] fa-solid-900.ttf exists
DEBUG  [2023-09-15 18:30:00] fa-brands-400.ttf exists
DEBUG  [2023-09-15 18:30:00] Lab folder exists
[New Thread 15092.0x34b0]
[New Thread 15092.0x4fe0]
[New Thread 15092.0x5ad4]
[New Thread 15092.0x3c14]
[New Thread 15092.0x3bc8]
[New Thread 15092.0x3bf0]
[Thread 15092.0x3bc8 exited with code 0]
[Thread 15092.0x3bf0 exited with code 0]
[New Thread 15092.0x5864]
[Thread 15092.0x3c14 exited with code 0]
[New Thread 15092.0x383c]
[New Thread 15092.0x3490]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff6200bb5f0 in ImFontGlyphRangesBuilder::BuildRanges(ImVector<unsigned int>*) ()

@gucio321
Copy link
Collaborator

meh, Can't see anyghing useful unfortunately.
My guss is that, because this file isn't auto-generated in fact, we should try to autogenerate it

@Wolf65
Copy link
Author

Wolf65 commented Sep 16, 2023

on one of the restarts, instead of symbols.
image
expected
image

@ptxmac
Copy link
Contributor

ptxmac commented Sep 29, 2023

I'm hitting this problem too. Did some git bisect testing and found that the bug was introduced in #204

@ptxmac
Copy link
Contributor

ptxmac commented Sep 30, 2023

I did a little more research and found the change that cause the issue:

diff --git a/cimgui_structs.go b/cimgui_structs.go
index a53d5778..1b69681a 100644
--- a/cimgui_structs.go
+++ b/cimgui_structs.go
@@ -522,13 +522,24 @@ func newFontGlyphFromC(cvalue *C.ImFontGlyph) *FontGlyph {
 // Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges().
 // This is essentially a tightly packed of vector of 64k booleans = 8KB storage.
 type FontGlyphRangesBuilder struct {
-	// TODO: contains unsupported fields
-	data unsafe.Pointer
+	FieldUsedChars Vector[*uint32] // Store 1-bit per Unicode code point (0=unused, 1=used)
 }
 
 func (self FontGlyphRangesBuilder) handle() (result *C.ImFontGlyphRangesBuilder, releaseFn func()) {
-	result = (*C.ImFontGlyphRangesBuilder)(self.data)
-	return result, func() {}
+	result = new(C.ImFontGlyphRangesBuilder)
+	FieldUsedChars := self.FieldUsedChars
+	FieldUsedCharsData := FieldUsedChars.Data
+	FieldUsedCharsDataArg, FieldUsedCharsDataFin := WrapNumberPtr[C.ImU32, uint32](FieldUsedCharsData)
+	FieldUsedCharsVecArg := new(C.ImVector_ImU32)
+	FieldUsedCharsVecArg.Size = C.int(FieldUsedChars.Size)
+	FieldUsedCharsVecArg.Capacity = C.int(FieldUsedChars.Capacity)
+	FieldUsedCharsVecArg.Data = FieldUsedCharsDataArg
+
+	result.UsedChars = *FieldUsedCharsVecArg
+	releaseFn = func() {
+		FieldUsedCharsDataFin()
+	}
+	return result, releaseFn
 }
 
 func (self FontGlyphRangesBuilder) c() (result C.ImFontGlyphRangesBuilder, fin func()) {
@@ -538,7 +549,7 @@ func (self FontGlyphRangesBuilder) c() (result C.ImFontGlyphRangesBuilder, fin f
 
 func newFontGlyphRangesBuilderFromC(cvalue *C.ImFontGlyphRangesBuilder) *FontGlyphRangesBuilder {
 	result := new(FontGlyphRangesBuilder)
-	result.data = unsafe.Pointer(cvalue)
+	result.FieldUsedChars = newVectorFromC(cvalue.UsedChars.Size, cvalue.UsedChars.Capacity, (*uint32)(cvalue.UsedChars.Data))
 	return result
 }

@gucio321
Copy link
Collaborator

IDK what happens here. I'll think about it but can't promise any other actionn on my side as I have no fast enough laptop here and this one is a bit too slow to effectively recompile cimgui-go so I can't do any tests now.

@ptxmac
Copy link
Contributor

ptxmac commented Sep 30, 2023

I have a suspicion that the glyph range is not supposed to be deallocated...

Here's a sample of how it's used to load a font sith a specific set of glyphs:

	bld := cimgui.NewFontGlyphRangesBuilder()
	bld.AddRanges(atlas.GlyphRangesDefault())
	bld.AddChar(cimgui.Wchar('⌘'))

	rng := cimgui.NewGlyphRange()
	bld.BuildRanges(rng)

	atlas.AddFontFromMemoryTTFV(ptr, int32(len(data)), pixelSize, cfg, rng.Data())

I think rng.Data() just gives a pointer to the first entry in the glyph array and imgui doesn't copy it.
So when the range builder is released, so is the array imgui is using

@gucio321
Copy link
Collaborator

maybe... could you try to Pin result of rng.Data()
ALso its not a pointer to first index. Its a pointer to ImVector (in go code Vector[Wchar]) but yes, it is possible that something is released by GC

@ptxmac
Copy link
Contributor

ptxmac commented Sep 30, 2023

I diff above was a bit outdated... on the latest main the data is actually pinned

diff --git a/cimgui_structs.go b/cimgui_structs.go
index 36b723f1..f59703ad 100644
--- a/cimgui_structs.go
+++ b/cimgui_structs.go
@@ -530,13 +530,26 @@ func newFontGlyphFromC(cvalue *C.ImFontGlyph) *FontGlyph {
 // Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges().
 // This is essentially a tightly packed of vector of 64k booleans = 8KB storage.
 type FontGlyphRangesBuilder struct {
-	// TODO: contains unsupported fields
-	data unsafe.Pointer
+	FieldUsedChars Vector[*uint32] // Store 1-bit per Unicode code point (0=unused, 1=used)
 }
 
 func (self FontGlyphRangesBuilder) handle() (result *C.ImFontGlyphRangesBuilder, releaseFn func()) {
-	result = (*C.ImFontGlyphRangesBuilder)(self.data)
-	return result, func() {}
+	result = new(C.ImFontGlyphRangesBuilder)
+	FieldUsedChars := self.FieldUsedChars
+	FieldUsedCharsData := FieldUsedChars.Data
+	FieldUsedCharsDataArg, FieldUsedCharsDataFin := WrapNumberPtr[C.ImU32, uint32](FieldUsedCharsData)
+	FieldUsedCharsVecArg := new(C.ImVector_ImU32)
+	FieldUsedCharsVecArg.Size = C.int(FieldUsedChars.Size)
+	FieldUsedCharsVecArg.Capacity = C.int(FieldUsedChars.Capacity)
+	FieldUsedCharsVecArg.Data = FieldUsedCharsDataArg
+	FieldUsedChars.pinner.Pin(FieldUsedCharsVecArg.Data)
+
+	result.UsedChars = *FieldUsedCharsVecArg
+	releaseFn = func() {
+		FieldUsedCharsDataFin()
+		FieldUsedChars.pinner.Unpin()
+	}
+	return result, releaseFn
 }
 
 func (self FontGlyphRangesBuilder) c() (result C.ImFontGlyphRangesBuilder, fin func()) {
@@ -546,7 +559,7 @@ func (self FontGlyphRangesBuilder) c() (result C.ImFontGlyphRangesBuilder, fin f
 
 func newFontGlyphRangesBuilderFromC(cvalue *C.ImFontGlyphRangesBuilder) *FontGlyphRangesBuilder {
 	result := new(FontGlyphRangesBuilder)
-	result.data = unsafe.Pointer(cvalue)
+	result.FieldUsedChars = newVectorFromC(cvalue.UsedChars.Size, cvalue.UsedChars.Capacity, (*uint32)(cvalue.UsedChars.Data))
 	return result
 }
 

Unfortuantely that's didn't change anything

@gucio321
Copy link
Collaborator

meh I see. I suppose this whole BuildRanges is broken because in current code it is not auto-generated. It used to work before my changes to struct generation and beffore implementing Vector type.
I think we codegen needs to implement Vector pointer so that we could get rid of this uintptr in GlyphRanges.

@ptxmac
Copy link
Contributor

ptxmac commented Sep 30, 2023

It's been a while since I've worked with this repo, so I don't have enough insight to comment on that - But I'll be happy to test any changes 😄

@gucio321
Copy link
Collaborator

I'll try to fix this but can't say when could it happen...

@ptxmac
Copy link
Contributor

ptxmac commented Sep 30, 2023

No worries, I've just hacked it my apply the patch above

If any one else is having this problem, a temporary solution is to use my branch which patches this: https://github.com/ptxmac/cimgui-go/tree/ptx_fixes

Right now it's up to date with main

gucio321 added a commit to gucio321/cimgui-go that referenced this issue Nov 7, 2023
gengo_structs.go seemd to be extremely useful, however
it generated several bugs that cannot be fixed using that engine.

Some of the reported issues are:
- AllenDang#206
@gucio321
Copy link
Collaborator

@ptxmac It should work #229

@gucio321 gucio321 linked a pull request Nov 14, 2023 that will close this issue
@ptxmac
Copy link
Contributor

ptxmac commented Nov 21, 2023

@ptxmac It should work #229

This fixed the font issues, there are some other things about the change that breaks other stuff, but I'll add that as comments on the PR

gucio321 added a commit to gucio321/cimgui-go that referenced this issue Dec 18, 2023
gengo_structs.go seemd to be extremely useful, however
it generated several bugs that cannot be fixed using that engine.

Some of the reported issues are:
- AllenDang#206
gucio321 added a commit to gucio321/cimgui-go that referenced this issue Dec 20, 2023
gengo_structs.go seemd to be extremely useful, however
it generated several bugs that cannot be fixed using that engine.

Some of the reported issues are:
- AllenDang#206
@ptxmac
Copy link
Contributor

ptxmac commented Feb 17, 2024

This works for me now! 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigating Searching for origins of the issue.
Projects
None yet
3 participants