fix(context-menu): use puregotk pointer type checks
- commit
- ba33fa252c15cec703c58a955e024eb1999718cc
- author
- brice · · 2026-04-14 18:04 UTC
- parent
- 0a87b78
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +5 -6
M go.mod +1 -1
| @@ -7,7 +7,7 @@ require ( | |||
| 7 | 7 | github.com/bnema/purego-ffmpeg v0.3.0 | |
| 8 | 8 | github.com/bnema/purego-pipewire v0.1.1 | |
| 9 | 9 | github.com/bnema/purego-sqlite v0.1.1 | |
| 10 | - | github.com/bnema/puregotk v0.3.0 | |
| 10 | + | github.com/bnema/puregotk v0.4.0 | |
| 11 | 11 | github.com/bnema/puregotk-webkit v0.0.16 | |
| 12 | 12 | github.com/charmbracelet/bubbles v1.0.0 | |
| 13 | 13 | github.com/charmbracelet/bubbletea v1.3.10 | |
| @@ -7,7 +7,7 @@ require ( | |||||
| 7 | github.com/bnema/purego-ffmpeg v0.3.0 | 7 | github.com/bnema/purego-ffmpeg v0.3.0 | ||
| 8 | github.com/bnema/purego-pipewire v0.1.1 | 8 | github.com/bnema/purego-pipewire v0.1.1 | ||
| 9 | github.com/bnema/purego-sqlite v0.1.1 | 9 | github.com/bnema/purego-sqlite v0.1.1 | ||
| 10 | - | github.com/bnema/puregotk v0.3.0 | 10 | + | github.com/bnema/puregotk v0.4.0 |
| 11 | github.com/bnema/puregotk-webkit v0.0.16 | 11 | github.com/bnema/puregotk-webkit v0.0.16 | ||
| 12 | github.com/charmbracelet/bubbles v1.0.0 | 12 | github.com/charmbracelet/bubbles v1.0.0 | ||
| 13 | github.com/charmbracelet/bubbletea v1.3.10 | 13 | github.com/charmbracelet/bubbletea v1.3.10 | ||
M go.sum +2 -2 generated file: collapsed
M internal/infrastructure/gtkmenu/renderer.go +1 -2
| @@ -5,7 +5,6 @@ import ( | |||
| 5 | 5 | "github.com/bnema/puregotk/v4/gdk" | |
| 6 | 6 | "github.com/bnema/puregotk/v4/gobject" | |
| 7 | 7 | "github.com/bnema/puregotk/v4/gtk" | |
| 8 | - | "unsafe" | |
| 9 | 8 | ) | |
| 10 | 9 | ||
| 11 | 10 | type renderItem struct { | |
| @@ -200,7 +199,7 @@ func overlayFromWidget(widget *gtk.Widget) *gtk.Overlay { | |||
| 200 | 199 | if widget == nil || widget.GoPointer() == 0 { | |
| 201 | 200 | return nil | |
| 202 | 201 | } | |
| 203 | - | if !gobject.TypeCheckInstanceIsA((*gobject.TypeInstance)(unsafe.Pointer(widget.GoPointer())), gtk.OverlayGLibType()) { | |
| 202 | + | if !gobject.TypeCheckInstanceIsAPtr(widget.GoPointer(), gtk.OverlayGLibType()) { | |
| 204 | 203 | return nil | |
| 205 | 204 | } | |
| 206 | 205 | return gtk.OverlayNewFromInternalPtr(widget.GoPointer()) | |
| @@ -5,7 +5,6 @@ import ( | |||||
| 5 | "github.com/bnema/puregotk/v4/gdk" | 5 | "github.com/bnema/puregotk/v4/gdk" | ||
| 6 | "github.com/bnema/puregotk/v4/gobject" | 6 | "github.com/bnema/puregotk/v4/gobject" | ||
| 7 | "github.com/bnema/puregotk/v4/gtk" | 7 | "github.com/bnema/puregotk/v4/gtk" | ||
| 8 | - | "unsafe" | |||
| 9 | ) | 8 | ) | ||
| 10 | 9 | ||||
| 11 | type renderItem struct { | 10 | type renderItem struct { | ||
| @@ -200,7 +199,7 @@ func overlayFromWidget(widget *gtk.Widget) *gtk.Overlay { | |||||
| 200 | if widget == nil || widget.GoPointer() == 0 { | 199 | if widget == nil || widget.GoPointer() == 0 { | ||
| 201 | return nil | 200 | return nil | ||
| 202 | } | 201 | } | ||
| 203 | - | if !gobject.TypeCheckInstanceIsA((*gobject.TypeInstance)(unsafe.Pointer(widget.GoPointer())), gtk.OverlayGLibType()) { | 202 | + | if !gobject.TypeCheckInstanceIsAPtr(widget.GoPointer(), gtk.OverlayGLibType()) { |
| 204 | return nil | 203 | return nil | ||
| 205 | } | 204 | } | ||
| 206 | return gtk.OverlayNewFromInternalPtr(widget.GoPointer()) | 205 | return gtk.OverlayNewFromInternalPtr(widget.GoPointer()) | ||
M internal/infrastructure/webkit/context_menu_test.go +1 -1
| @@ -232,7 +232,7 @@ func TestResolveImageData(t *testing.T) { | |||
| 232 | 232 | }) | |
| 233 | 233 | ||
| 234 | 234 | t.Run("rejects spoofed image headers when sniffed bytes are not an image", func(t *testing.T) { | |
| 235 | - | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
| 235 | + | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { | |
| 236 | 236 | w.Header().Set("Content-Type", "image/png") | |
| 237 | 237 | w.Write([]byte("<html><body>not really an image</body></html>")) | |
| 238 | 238 | })) | |
| @@ -232,7 +232,7 @@ func TestResolveImageData(t *testing.T) { | |||||
| 232 | }) | 232 | }) | ||
| 233 | 233 | ||||
| 234 | t.Run("rejects spoofed image headers when sniffed bytes are not an image", func(t *testing.T) { | 234 | t.Run("rejects spoofed image headers when sniffed bytes are not an image", func(t *testing.T) { | ||
| 235 | - | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | 235 | + | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 236 | w.Header().Set("Content-Type", "image/png") | 236 | w.Header().Set("Content-Type", "image/png") | ||
| 237 | w.Write([]byte("<html><body>not really an image</body></html>")) | 237 | w.Write([]byte("<html><body>not really an image</body></html>")) | ||
| 238 | })) | 238 | })) | ||