mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-15 15:15:51 +01:00
* fix(v3): warm up dialog types in go-json cache to prevent Windows panic Add FileFilter, OpenFileDialogOptions, SaveFileDialogOptions, and MessageDialogOptions to the init() warmup to prevent index out of bounds panic on Windows when these types are first unmarshaled. Fixes goccy/go-json#474 for Wails internal dialog types. * fix(v3): revert goccy/go-json to stdlib encoding/json to fix Windows panic goccy/go-json has a type address calculation bug on Windows that causes index out of bounds panic when decoding user-defined types for the first time. This reverts all runtime usages of goccy/go-json back to stdlib encoding/json. Test and benchmark files are left unchanged. Partially reverts PR #4843.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package application
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/errs"
|
|
)
|
|
|
|
const (
|
|
EventsEmit = 0
|
|
)
|
|
|
|
var eventsMethodNames = map[int]string{
|
|
EventsEmit: "Emit",
|
|
}
|
|
|
|
func (m *MessageProcessor) processEventsMethod(req *RuntimeRequest, window Window) (any, error) {
|
|
switch req.Method {
|
|
case EventsEmit:
|
|
var event CustomEvent
|
|
var options struct {
|
|
Name *string `json:"name"`
|
|
Data json.RawMessage `json:"data"`
|
|
}
|
|
|
|
err := req.Args.ToStruct(&options)
|
|
if err != nil {
|
|
return nil, errs.WrapInvalidEventsCallErrorf(err, "error parsing event")
|
|
}
|
|
if options.Name == nil {
|
|
return nil, errs.NewInvalidEventsCallErrorf("missing event name")
|
|
}
|
|
|
|
data, err := decodeEventData(*options.Name, options.Data)
|
|
if err != nil {
|
|
return nil, errs.WrapInvalidEventsCallErrorf(err, "error parsing event data")
|
|
}
|
|
|
|
event.Name = *options.Name
|
|
event.Data = data
|
|
event.Sender = window.Name()
|
|
globalApplication.Event.EmitEvent(&event)
|
|
|
|
return event.IsCancelled(), nil
|
|
default:
|
|
return nil, errs.NewInvalidEventsCallErrorf("unknown method: %d", req.Method)
|
|
}
|
|
}
|