asticode / astilectron

Electron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events
MIT License
285 stars 67 forks source link

Use second-instance, if lastWindow destroy, crash: Object has been destroyed #40

Closed oldfeel closed 3 years ago

oldfeel commented 3 years ago

image

asticode commented 3 years ago

Can you provide a way to reproduce the problem?

oldfeel commented 3 years ago

Can you provide a way to reproduce the problem?


// Initialize astilectron
var a, _ = astilectron.New(log.New(os.Stderr, "", 0), astilectron.Options{
SingleInstance: true,
AppName:        "qocr",
})
defer a.Close()
// Start astilectron
a.Start()

// Create a new window
var w1, _ = a.NewWindow("http://127.0.0.1:4000", &astilectron.WindowOptions{
    Center: astikit.BoolPtr(true),
    Height: astikit.IntPtr(600),
    Width:  astikit.IntPtr(600),
})
w1.Create()

// Create a new window
var w2, _ = a.NewWindow("http://127.0.0.1:4000", &astilectron.WindowOptions{
    Center: astikit.BoolPtr(true),
    Height: astikit.IntPtr(600),
    Width:  astikit.IntPtr(600),
})
w2.Create()

w2.Destroy()

// Blocking pattern
a.Wait()


Crash on the second run.
asticode commented 3 years ago

I've pushed a fix.

You need to get the latest changes for go-astilectron and (if you're using them) go-astilectron-bundler + go-astilectron-bootstrap.

In case you're using go-astilectron-bundler you need to run go install ./astilectron-bundler as well.

Can you confirm this is working properly?

oldfeel commented 3 years ago

It's OK, thank you very much!