Closed
Description
Try running this test:
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) 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);
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)
}
}
I'm receiving a long about 3 seconds worth of the expected output and then all of a sudden:
2014/05/26 12:45:42 blah.qml:13: dummy2(0x5f0c820)
2014/05/26 12:45:42 blah.qml:15: 0
2014/05/26 12:45:42 blah.qml:11: dummy(0x6d179f0)
2014/05/26 12:45:42 blah.qml:13: dummy2(0x5f0c820)
2014/05/26 12:45:42 blah.qml:15: 0
2014/05/26 12:45:42 blah.qml:11: dummy(0x6d179f0)
2014/05/26 12:45:42 blah.qml:13: dummy2(0x5f0c820)
2014/05/26 12:45:42 blah.qml:15: 0
2014/05/26 12:45:42 blah.qml:11: dummy(0x6d179f0)
2014/05/26 12:45:42 blah.qml:13: dummy2(0x5f0c820)
2014/05/26 12:45:42 blah.qml:15: 0
2014/05/26 12:45:42 blah.qml:11: dummy(0x6d179f0)
2014/05/26 12:45:42 blah.qml:13: dummy2(0x5f0c820)
2014/05/26 12:45:42 blah.qml:15: 0
2014/05/26 12:45:42 blah.qml:11: dummy(0x6d179f0)
2014/05/26 12:45:42 blah.qml:13: null
2014/05/26 12:45:42 blah.qml:14: file:////private/tmp/blah.qml:14: TypeError: Cannot call method 'b' of null
--- FAIL: TestBlah (3.01 seconds)
FAIL
exit status 1
FAIL _/private/tmp 3.120s
If I don't fail immediately, it'll output the correct data again for a bit until it fails the next time.
Occurs in both v0 and v1
Metadata
Metadata
Assignees
Labels
No labels