Comments (7)
Panicing variant when trying to use the return value of d.a
as a function parameter:
package qml_test
import (
"gopkg.in/qml.v1"
"testing"
"time"
)
func init() {
qml.SetupTesting()
}
type (
Blah struct {
A int
}
dummy2 struct {
b Blah
}
dummy struct {
d dummy2
}
)
func (d *dummy2) B() Blah {
return d.b
}
func (d *dummy) C(*dummy2) {
}
func (d *dummy) A() *dummy2 {
return &d.d
}
func TestBlah(t *testing.T) {
// qml.Init(nil)
f := func() error {
e := qml.NewEngine()
defer e.Destroy()
var d dummy
e.Context().SetVar("d", &d)
c, err := e.LoadString("blah.qml", `
import QtQuick 2.0
Item {
Timer {
objectName: "ti";
interval: 10
running: true
repeat: true
onTriggered: {
running = false;
console.log(d);
var a = d.a();
console.log(a);
d.c(a);
var b = a.b(0);
console.log(b.a);
running = true;
}
}
}
`)
if err != nil {
return err
}
w := c.Create(nil)
defer w.Destroy()
o := w.ObjectByName("ti") //.ObjectByName("ti")
defer o.Destroy()
failed := false
for i := 0; i < 30; i++ {
if b, ok := o.Property("running").(bool); !b && ok {
failed = true
break
}
time.Sleep(time.Second)
}
if failed {
t.FailNow()
}
return nil
}
err := f()
if err != nil {
t.Error(err)
}
}
Output:
2014/05/26 12:59:08 blah.qml:11: dummy(0x6e0ed60)
2014/05/26 12:59:08 blah.qml:13: dummy2(0x6837820)
2014/05/26 12:59:08 blah.qml:16: 0
2014/05/26 12:59:08 blah.qml:11: dummy(0x6e0ed60)
2014/05/26 12:59:08 blah.qml:13: dummy2(0x6837820)
2014/05/26 12:59:08 blah.qml:16: 0
2014/05/26 12:59:08 blah.qml:11: dummy(0x6e0ed60)
2014/05/26 12:59:08 blah.qml:13: dummy2(0x6837820)
2014/05/26 12:59:08 blah.qml:16: 0
2014/05/26 12:59:08 blah.qml:11: dummy(0x6e0ed60)
2014/05/26 12:59:08 blah.qml:13: null
panic: reflect: call of reflect.Value.Type on zero Value
goroutine 16 [running]:
runtime.panic(0x41a97c0, 0xc2080a4bc0)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:279 +0xf5
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/quarnster/code/3rdparty/go/src/pkg/reflect/value.go:1836 +0x92
gopkg.in/qml%2ev1.hookGoValueCallMethod(0x6d21e50, 0xc208030360, 0x7fff00000001, 0x7fff5fbfc650)
/Users/quarnster/code/go/src/gopkg.in/qml.v1/bridge.go:506 +0x31b
gopkg.in/qml%2ev1._Cfunc_applicationExec(0x41b6b60)
gopkg.in/qml.v1/_obj/_cgo_defun.c:71 +0x31
gopkg.in/qml%2ev1.Run(0x0, 0x422fa78, 0x0, 0x0)
/Users/quarnster/code/go/src/gopkg.in/qml.v1/bridge.go:68 +0x1b1
gopkg.in/qml%2ev1.qmain()
/Users/quarnster/code/go/src/gopkg.in/qml.v1/testing.go:17 +0x30
goroutine 19 [finalizer wait]:
runtime.park(0x4064ab0, 0x42d6bf8, 0x42caec9)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1354 +0x89
runtime.parkunlock(0x42d6bf8, 0x42caec9)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1370 +0x3b
runfinq()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/mgc0.c:2624 +0xcf
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1430
goroutine 17 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1430
goroutine 20 [chan receive]:
testing.RunTests(0x422fb10, 0x42c3300, 0x1, 0x1, 0x1)
/Users/quarnster/code/3rdparty/go/src/pkg/testing/testing.go:504 +0x917
testing.Main(0x422fb10, 0x42c3300, 0x1, 0x1, 0x42de540, 0x0, 0x0, 0x42de540, 0x0, 0x0)
/Users/quarnster/code/3rdparty/go/src/pkg/testing/testing.go:435 +0x87
main.main()
_/private/tmp/_test/_testmain.go:47 +0x9c
gopkg.in/qml%2ev1.tmain()
/Users/quarnster/code/go/src/gopkg.in/qml.v1/testing.go:20 +0x1a
gopkg.in/qml%2ev1.func·035(0x0, 0x0)
/Users/quarnster/code/go/src/gopkg.in/qml.v1/testing.go:17 +0x2c
gopkg.in/qml%2ev1.func·002()
/Users/quarnster/code/go/src/gopkg.in/qml.v1/bridge.go:65 +0x46
created by gopkg.in/qml%2ev1.Run
/Users/quarnster/code/go/src/gopkg.in/qml.v1/bridge.go:67 +0x1aa
goroutine 21 [sleep]:
time.Sleep(0x3b9aca00)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/time.goc:39 +0x31
_/private/tmp_test.func·001(0x0, 0x0)
/private/tmp/blah_test.go:78 +0x2d8
_/private/tmp_test.TestBlah(0xc208068090)
/private/tmp/blah_test.go:85 +0x4f
testing.tRunner(0xc208068090, 0x42c3300)
/Users/quarnster/code/3rdparty/go/src/pkg/testing/testing.go:422 +0x8b
created by testing.RunTests
/Users/quarnster/code/3rdparty/go/src/pkg/testing/testing.go:503 +0x8cf
exit status 2
FAIL _/private/tmp 2.077s
from qml.
The problem is the same described in this thread:
https://groups.google.com/d/msg/go-qml/h5gDOjyE8Yc/jyG9Pia2GaMJ
As explained there, the QML engine is destroying the old proxy object even though it was just handed a reference to it, which seems like bug, but I won't argue about that nor expect it to be timely fixed. Instead, I'm planning to simplify significantly the reference handling logic by making Go own all the values, and use its garbage collector to release resources on the QML side.
I'll keep you posted via this ticket.
from qml.
Got it, thanks, I'll keep my eyes and ears open :)
from qml.
Sorry it's taking a while to get to this. I'll move it up in the agenda and will go back to it after the new gl package structure is working.
from qml.
I'm back into this. Should have a fix shortly.
from qml.
Okay, rather than changing too much right now, I'm going for a more conservative approach which I should have implemented long ago.
from qml.
Excellent! Appears to work fine from very minor testing, thanks! :)
from qml.
Related Issues (20)
- Can we use QT5 with Microsoft VS2015 Community?
- Statically compiling with qt/qml for a truly standalone app HOT 9
- Something wrong with WebView HOT 3
- Install on Mac without Homebrew
- cgo result has Go pointer
- go-qml is broken under Go 1.7 HOT 21
- Error Build a sample HOT 3
- How Build and Install QT on Go 1.8?
- Error Build
- Tray icon/menu support
- types foe model QML
- Error! HOT 1
- Error while building/testing on windows HOT 1
- How do I register a singleton qml file/component
- Qt 5.11 Support HOT 6
- Broken under Go 1.12 (relocation target runtime.acquirem not defined for ABI0 (but is defined for ABIInternal)) HOT 5
- build go-qml failure HOT 1
- How to connect Material?
- on Mac QT 5.13.0 + Go 1.12.7 installing error when did 'go get gopkg.in/qml.v1' HOT 1
- Installation on Ubuntu 19.10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qml.