Skip to content

Commit

Permalink
Ensure internal state is initialised from external APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Oct 10, 2023
1 parent b8c846f commit 838ba7d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/gui/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type cont struct {
// DecodeJSON returns a tree of `CanvasObject` elements from the provided JSON `Reader` and
// the tree of wrapped elements that describe their metadata.
func DecodeJSON(r io.Reader) (fyne.CanvasObject, map[fyne.CanvasObject]map[string]string) {
guidefs.InitOnce()

var data interface{}
_ = json.NewDecoder(r).Decode(&data)
if data == nil {
Expand All @@ -55,6 +57,8 @@ func DecodeJSON(r io.Reader) (fyne.CanvasObject, map[fyne.CanvasObject]map[strin
// EncodeJSON writes a JSON stream for the tree of `CanvasObject` elements provided.
// If an error occurs it will be returned, otherwise nil.
func EncodeJSON(obj fyne.CanvasObject, meta map[fyne.CanvasObject]map[string]string, w io.Writer) error {
guidefs.InitOnce()

tree := encodeObj(obj, meta)

e := json.NewEncoder(w)
Expand Down

0 comments on commit 838ba7d

Please sign in to comment.