sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.58k stars 268 forks source link

Long time use sciter.Element.SetText("") occur #214

Open matthew-sharp-lau opened 4 years ago

matthew-sharp-lau commented 4 years ago

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x4e04b9]

goroutine 1732 [running]: github.com/sciter-sdk/go-sciter.(Element).SetText.func1(0x0, 0x12214eb8, 0x4, 0 x4) C:/gospace/src/github.com/sciter-sdk/go-sciter/sciter.go:818 +0x19 github.com/sciter-sdk/go-sciter.(Element).SetText(0x0, 0x54c031, 0x3, 0x0, 0x57 7810) C:/gospace/src/github.com/sciter-sdk/go-sciter/sciter.go:818 +0x59 main.handleStatusData.func1()

How to fix the error, thank you!

matthew-sharp-lau commented 4 years ago

win7 32bit

pravic commented 4 years ago

Can't reproduce on x64: go version go1.11 windows/amd64

Could you modify the "download.go" and add an empty SetText("") there?

diff --git a/examples/download/download.go b/examples/download/download.go
index 3392656..50f1158 100644
--- a/examples/download/download.go
+++ b/examples/download/download.go
@@ -31,6 +31,7 @@ func load(w *window.Window, url string) {
                log.Panic(err)
        }
        log.Println("span:", text)
+       err = span.SetText("")
        err = span.SetText(url)
        if err != nil {
                log.Panic(err)
matthew-sharp-lau commented 4 years ago

I mean the SetText function, not just set the empty string. In my project, I use the SetText of div element to display my device status realtime , when my program run in minutes, the program was block and down, and the panic is above I refer to. I real like the go-sciter to write the interface for my program. Is the wrong way when I use SetText? How can I fix it? , Thank you very much!