Polish migration review fixes
- commit
- 1d1423765af723b4426074815739663c2d502508
- author
- brice · · 2026-04-29 20:27 UTC
- parent
- c3e55f7
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +20 -15
M internal/infrastructure/cef/cef2gtk_adapter.go +5 -4
| @@ -173,10 +173,11 @@ func (a *Cef2gtkAdapter) Diagnostics() cef2gtk.Diagnostics { | |||
| 173 | 173 | } | |
| 174 | 174 | ||
| 175 | 175 | // Destroy releases GL resources owned by purego-cef2gtk and disconnects GTK | |
| 176 | - | // signal handlers. Must be called on the GTK main thread. Not safe for | |
| 177 | - | // concurrent use; callers must ensure no concurrent adapter reads are in flight. | |
| 178 | - | // After Destroy, the adapter is marked destroyed and all subsequent operations | |
| 179 | - | // return ErrAdapterDestroyed. | |
| 176 | + | // signal handlers. Must be called on the GTK main thread. The atomic destroyed | |
| 177 | + | // flag only communicates lifecycle state; accesses to view are not otherwise | |
| 178 | + | // synchronized, so callers must ensure no concurrent adapter method is using the | |
| 179 | + | // view while Destroy runs. After Destroy, operations return ErrAdapterDestroyed | |
| 180 | + | // or a zero-value result. | |
| 180 | 181 | func (a *Cef2gtkAdapter) Destroy() error { | |
| 181 | 182 | if a == nil { | |
| 182 | 183 | return ErrAdapterDestroyed | |
| @@ -173,10 +173,11 @@ func (a *Cef2gtkAdapter) Diagnostics() cef2gtk.Diagnostics { | |||||
| 173 | } | 173 | } | ||
| 174 | 174 | ||||
| 175 | // Destroy releases GL resources owned by purego-cef2gtk and disconnects GTK | 175 | // Destroy releases GL resources owned by purego-cef2gtk and disconnects GTK | ||
| 176 | - | // signal handlers. Must be called on the GTK main thread. Not safe for | 176 | + | // signal handlers. Must be called on the GTK main thread. The atomic destroyed |
| 177 | - | // concurrent use; callers must ensure no concurrent adapter reads are in flight. | 177 | + | // flag only communicates lifecycle state; accesses to view are not otherwise |
| 178 | - | // After Destroy, the adapter is marked destroyed and all subsequent operations | 178 | + | // synchronized, so callers must ensure no concurrent adapter method is using the |
| 179 | - | // return ErrAdapterDestroyed. | 179 | + | // view while Destroy runs. After Destroy, operations return ErrAdapterDestroyed |
| 180 | + | // or a zero-value result. | |||
| 180 | func (a *Cef2gtkAdapter) Destroy() error { | 181 | func (a *Cef2gtkAdapter) Destroy() error { | ||
| 181 | if a == nil { | 182 | if a == nil { | ||
| 182 | return ErrAdapterDestroyed | 183 | return ErrAdapterDestroyed | ||
M internal/infrastructure/cef/cef2gtk_boundary_test.go +10 -6
| @@ -27,7 +27,11 @@ func TestCEF2GTKImportStaysInInfrastructureCEF(t *testing.T) { | |||
| 27 | 27 | if filepath.Ext(path) != ".go" || strings.HasSuffix(path, "_test.go") { | |
| 28 | 28 | return nil | |
| 29 | 29 | } | |
| 30 | - | if !importsCEF2GTK(path) { | |
| 30 | + | importsBridge, err := importsCEF2GTK(path) | |
| 31 | + | if err != nil { | |
| 32 | + | return err | |
| 33 | + | } | |
| 34 | + | if !importsBridge { | |
| 31 | 35 | return nil | |
| 32 | 36 | } | |
| 33 | 37 | rel, err := filepath.Rel(root, path) | |
| @@ -44,18 +48,18 @@ func TestCEF2GTKImportStaysInInfrastructureCEF(t *testing.T) { | |||
| 44 | 48 | } | |
| 45 | 49 | } | |
| 46 | 50 | ||
| 47 | - | func importsCEF2GTK(path string) bool { | |
| 51 | + | func importsCEF2GTK(path string) (bool, error) { | |
| 48 | 52 | file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly) | |
| 49 | 53 | if err != nil { | |
| 50 | - | return false | |
| 54 | + | return false, err | |
| 51 | 55 | } | |
| 52 | 56 | for _, spec := range file.Imports { | |
| 53 | 57 | importPath, err := strconv.Unquote(spec.Path.Value) | |
| 54 | - | if err == nil && importPath == "github.com/bnema/purego-cef2gtk" { | |
| 55 | - | return true | |
| 58 | + | if err == nil && strings.HasPrefix(importPath, "github.com/bnema/purego-cef2gtk") { | |
| 59 | + | return true, nil | |
| 56 | 60 | } | |
| 57 | 61 | } | |
| 58 | - | return false | |
| 62 | + | return false, nil | |
| 59 | 63 | } | |
| 60 | 64 | ||
| 61 | 65 | func repoRoot(t *testing.T) string { | |
| @@ -27,7 +27,11 @@ func TestCEF2GTKImportStaysInInfrastructureCEF(t *testing.T) { | |||||
| 27 | if filepath.Ext(path) != ".go" || strings.HasSuffix(path, "_test.go") { | 27 | if filepath.Ext(path) != ".go" || strings.HasSuffix(path, "_test.go") { | ||
| 28 | return nil | 28 | return nil | ||
| 29 | } | 29 | } | ||
| 30 | - | if !importsCEF2GTK(path) { | 30 | + | importsBridge, err := importsCEF2GTK(path) |
| 31 | + | if err != nil { | |||
| 32 | + | return err | |||
| 33 | + | } | |||
| 34 | + | if !importsBridge { | |||
| 31 | return nil | 35 | return nil | ||
| 32 | } | 36 | } | ||
| 33 | rel, err := filepath.Rel(root, path) | 37 | rel, err := filepath.Rel(root, path) | ||
| @@ -44,18 +48,18 @@ func TestCEF2GTKImportStaysInInfrastructureCEF(t *testing.T) { | |||||
| 44 | } | 48 | } | ||
| 45 | } | 49 | } | ||
| 46 | 50 | ||||
| 47 | - | func importsCEF2GTK(path string) bool { | 51 | + | func importsCEF2GTK(path string) (bool, error) { |
| 48 | file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly) | 52 | file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly) | ||
| 49 | if err != nil { | 53 | if err != nil { | ||
| 50 | - | return false | 54 | + | return false, err |
| 51 | } | 55 | } | ||
| 52 | for _, spec := range file.Imports { | 56 | for _, spec := range file.Imports { | ||
| 53 | importPath, err := strconv.Unquote(spec.Path.Value) | 57 | importPath, err := strconv.Unquote(spec.Path.Value) | ||
| 54 | - | if err == nil && importPath == "github.com/bnema/purego-cef2gtk" { | 58 | + | if err == nil && strings.HasPrefix(importPath, "github.com/bnema/purego-cef2gtk") { |
| 55 | - | return true | 59 | + | return true, nil |
| 56 | } | 60 | } | ||
| 57 | } | 61 | } | ||
| 58 | - | return false | 62 | + | return false, nil |
| 59 | } | 63 | } | ||
| 60 | 64 | ||||
| 61 | func repoRoot(t *testing.T) string { | 65 | func repoRoot(t *testing.T) string { | ||
M internal/infrastructure/cef/render_handler_adapter.go +5 -5
| @@ -8,14 +8,17 @@ import ( | |||
| 8 | 8 | ) | |
| 9 | 9 | ||
| 10 | 10 | func newDumberRenderHandler(wv *WebView) purecef.RenderHandler { | |
| 11 | + | if wv == nil || wv.viewBridge == nil { | |
| 12 | + | return nil | |
| 13 | + | } | |
| 11 | 14 | hooks := cef2gtk.Hooks{ | |
| 12 | 15 | OnUnsupportedPaint: func() { | |
| 13 | - | if wv != nil && wv.ctx != nil { | |
| 16 | + | if wv.ctx != nil { | |
| 14 | 17 | logging.FromContext(wv.ctx).Warn().Msg("cef: unsupported CPU paint from accelerated bridge") | |
| 15 | 18 | } | |
| 16 | 19 | }, | |
| 17 | 20 | OnError: func(err error) { | |
| 18 | - | if wv != nil && wv.ctx != nil { | |
| 21 | + | if wv.ctx != nil { | |
| 19 | 22 | logging.FromContext(wv.ctx).Warn().Err(err).Msg("cef: accelerated render bridge error") | |
| 20 | 23 | } | |
| 21 | 24 | }, | |
| @@ -23,9 +26,6 @@ func newDumberRenderHandler(wv *WebView) purecef.RenderHandler { | |||
| 23 | 26 | handleRenderTextSelectionChanged(wv, selectedText) | |
| 24 | 27 | }, | |
| 25 | 28 | } | |
| 26 | - | if wv == nil || wv.viewBridge == nil { | |
| 27 | - | return nil | |
| 28 | - | } | |
| 29 | 29 | return wv.viewBridge.RenderHandler(hooks) | |
| 30 | 30 | } | |
| 31 | 31 | ||
| @@ -8,14 +8,17 @@ import ( | |||||
| 8 | ) | 8 | ) | ||
| 9 | 9 | ||||
| 10 | func newDumberRenderHandler(wv *WebView) purecef.RenderHandler { | 10 | func newDumberRenderHandler(wv *WebView) purecef.RenderHandler { | ||
| 11 | + | if wv == nil || wv.viewBridge == nil { | |||
| 12 | + | return nil | |||
| 13 | + | } | |||
| 11 | hooks := cef2gtk.Hooks{ | 14 | hooks := cef2gtk.Hooks{ | ||
| 12 | OnUnsupportedPaint: func() { | 15 | OnUnsupportedPaint: func() { | ||
| 13 | - | if wv != nil && wv.ctx != nil { | 16 | + | if wv.ctx != nil { |
| 14 | logging.FromContext(wv.ctx).Warn().Msg("cef: unsupported CPU paint from accelerated bridge") | 17 | logging.FromContext(wv.ctx).Warn().Msg("cef: unsupported CPU paint from accelerated bridge") | ||
| 15 | } | 18 | } | ||
| 16 | }, | 19 | }, | ||
| 17 | OnError: func(err error) { | 20 | OnError: func(err error) { | ||
| 18 | - | if wv != nil && wv.ctx != nil { | 21 | + | if wv.ctx != nil { |
| 19 | logging.FromContext(wv.ctx).Warn().Err(err).Msg("cef: accelerated render bridge error") | 22 | logging.FromContext(wv.ctx).Warn().Err(err).Msg("cef: accelerated render bridge error") | ||
| 20 | } | 23 | } | ||
| 21 | }, | 24 | }, | ||
| @@ -23,9 +26,6 @@ func newDumberRenderHandler(wv *WebView) purecef.RenderHandler { | |||||
| 23 | handleRenderTextSelectionChanged(wv, selectedText) | 26 | handleRenderTextSelectionChanged(wv, selectedText) | ||
| 24 | }, | 27 | }, | ||
| 25 | } | 28 | } | ||
| 26 | - | if wv == nil || wv.viewBridge == nil { | |||
| 27 | - | return nil | |||
| 28 | - | } | |||
| 29 | return wv.viewBridge.RenderHandler(hooks) | 29 | return wv.viewBridge.RenderHandler(hooks) | ||
| 30 | } | 30 | } | ||
| 31 | 31 | ||||