go-sciter icon indicating copy to clipboard operation
go-sciter copied to clipboard

runtime error: cgo argument has Go pointer to Go pointer

Open ZeronoFreya opened this issue 5 years ago • 5 comments

params := args[0].Get("params")
paramsMap := make(map[string]string)
if params.IsObject() {
	params.EnumerateKeyValue(func(key, val *sciter.Value) bool {
		log.Println(key.String(), val.String())

		paramsMap[key.String()] = val.String()   // runtime error
		return true
	})
}
goroutine 1 [running]:
github.com/sciter-sdk/go-sciter.(*Value).EnumerateKeyValue.func1(0xc000060680, 0x646a80, 0xc00008a050, 0x70a101)
        C:/Users/dell/go/src/github.com/sciter-sdk/go-sciter/sciter.go:2235 +0x4f
github.com/sciter-sdk/go-sciter.(*Value).EnumerateKeyValue(0xc000060680, 0xc000048c60, 0x6, 0xc000060680)
        C:/Users/dell/go/src/github.com/sciter-sdk/go-sciter/sciter.go:2235 +0x71
main.setEventHandler.func1(0xc00008a020, 0x1, 0x1, 0x1)
        G:/Project/Moe/demo/moe.go:109 +0x59c
github.com/sciter-sdk/go-sciter.(*eventMapper).toEventHandler.func7(0xc0000d0500, 0x10ef010, 0x2030000)
        C:/Users/dell/go/src/github.com/sciter-sdk/go-sciter/wrapper.go:123 +0xc0
github.com/sciter-sdk/go-sciter.goElementEventProc(0x0, 0x0, 0x400, 0x10ef010, 0x28)
        C:/Users/dell/go/src/github.com/sciter-sdk/go-sciter/sciter.go:1462 +0x4c1
github.com/sciter-sdk/go-sciter._cgoexpwrap_b3b3630205f5_goElementEventProc(0x0, 0x0, 0x400, 0x10ef010, 0x0)
        _cgo_gotypes.go:2000 +0x50
syscall.Syscall(0x7fff260816b0, 0x1, 0xc000089eb8, 0x0, 0x0, 0x0, 0x0, 0x0)
        D:/Program Files/Go/src/runtime/syscall_windows.go:188 +0xfa
github.com/lxn/win.DispatchMessage(0xc000089eb8, 0x0)
        C:/Users/dell/go/src/github.com/lxn/win/user32.go:2294 +0x67
github.com/sciter-sdk/go-sciter/window.(*Window).Run(0xc000048b30)
        C:/Users/dell/go/src/github.com/sciter-sdk/go-sciter/window/window_windows.go:61 +0x54
main.main()
        G:/Project/Moe/demo/moe.go:184 +0x1c1

What should I do? Thanks!

ZeronoFreya avatar Nov 26 '19 01:11 ZeronoFreya

Could you provide the full error message?

pravic avatar Nov 26 '19 12:11 pravic

Could you provide the full error message?

@pravic Only these:

panic: runtime error: cgo argument has Go pointer to Go pointer

moe.go

package main

import (
	"log"

	"github.com/sciter-sdk/go-sciter"
	"github.com/sciter-sdk/go-sciter/window"
)

func setEventHandler(w *window.Window) {
	
	w.DefineFunction("moeRequest", func(args ...*sciter.Value) *sciter.Value {
		params := args[0].Get("params")
		paramsMap := make(map[string]string)
		if params.IsObject() {
			params.EnumerateKeyValue(func(key, val *sciter.Value) bool {
				log.Println(key.String(), val.String())

				paramsMap[key.String()] = val.String()
				return true
			})
		}
		return sciter.NewValue("233")
	})
}
func main() {
	w, err := window.New(sciter.SW_TITLEBAR|
		sciter.SW_RESIZEABLE|
		sciter.SW_CONTROLS|
		sciter.SW_MAIN|
		sciter.SW_ENABLE_DEBUG,
		&sciter.Rect{Left: 0, Top: 0, Right: 500, Bottom: 500})
	if err != nil {
		log.Fatal(err)
	}
	ok := w.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_FILE_IO|
		sciter.ALLOW_SOCKET_IO|
		sciter.ALLOW_EVAL|
		sciter.ALLOW_SYSINFO)
	if !ok {
		log.Println("enable full fetures failed")
	}
	fp, err := filepath.Abs("scapp.html")
	if err != nil {
		log.Fatal(err)
	}
	w.LoadFile(fp)
	w.SetTitle("表单")
	setEventHandler(w)
	w.Show()
	w.Run()
}

html

<html>

<head>
    <title></title>
</head>

<body>
<button id="btn">click</button>
</body>
<script type="text/tiscript">
async function getData(){
  const str = await view.moeRequest{
    params:{
      page: 233
    }
  }
  view.msgbox( #information, str);
}
$(#btn).on("click",function(){
    getData()
})
</script>

</html>

ZeronoFreya avatar Nov 27 '19 07:11 ZeronoFreya

Thanks, will check it

pravic avatar Nov 27 '19 08:11 pravic

How did it go? Thanks!

ZeronoFreya avatar Dec 19 '19 09:12 ZeronoFreya

@ZeronoFreya Didn't have a chance to check this up yet, unfortunately.

pravic avatar Dec 19 '19 15:12 pravic