Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Commit

Permalink
Set main window as master and use SetOnClosed() instead of defer
Browse files Browse the repository at this point in the history
This should hopefully be a small optimization by running the function on close instead of defering it and keeping it in the call stack.
  • Loading branch information
Jacalz committed Jun 15, 2020
1 parent 7aa8d7a commit e08e92b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/gui/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func Init() {

// Create the window for our user interface.
w := a.NewWindow("Sparta")
w.SetMaster()

// Create the user struct type for later use.
u := newUser()
Expand All @@ -65,14 +66,14 @@ func Init() {
t := &widget.TabContainer{}
t.Append(u.loginTabContainer(a, w, t))

// Defer creation and storage of a new password hash with random salt.
defer func() {
// Create and store of a new password hash with random salt on window close.
w.SetOnClosed(func() {
if key, err := crypto.SaveNewPasswordHash(u.password, u.username, a); err != nil {
fyne.LogError("Error on generating password hash", err)
} else {
u.data.Write(&key, u.username)
}
}()
})

// Set the window to a good size, add the content and lastly run the application.
w.SetContent(t)
Expand Down

0 comments on commit e08e92b

Please sign in to comment.