saltosystems / winrt-go

MIT License
35 stars 14 forks source link

delegates: allocate VTable in heap #95

Closed jagobagascon closed 6 months ago

jagobagascon commented 6 months ago

The VTable is a field all WinRT types have and it is used to store pointers to all the class functions. This field is usually created by WinRT, but for delegates we need to provide our own VTable instance.

We were previously using a Go struct pointer as our VTable, but Go structs can be randomly moved or GCed by the Go runtime, and since we are pasing the VTable to WinRT (out of the Go runtime), we were getting random invalid memory errors.

This was addressed in a previous PR (#64) but somehow we missed this.

fixes #94