GithubHelp home page GithubHelp logo

qml's People

Contributors

adg avatar cookieo9 avatar cristim avatar dmikalova avatar dupoxy avatar eivindro avatar jhawk28 avatar lomoalbert avatar niemeyer avatar owenthereal avatar quarnster avatar tmc avatar tsdgeos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qml's Issues

Test "Custom Go type with painting" failing on HasLen 1

I have the latest version of qml, but this error happened with older versions too.

I have Qt version 5.0.2. Go version go1.3rc1 linux/amd64 (but error also with older version), gcc version 4.8.2

Test log:

=== RUN Test

----------------------------------------------------------------------
FAIL: qml_test.go:1183: S.TestTable

----- Running table test 0: Read a context variable and its fields -----
[LOG] 36.85478 file.qml:5: String is <content>
[LOG] 36.85478 file.qml:6: Int is 42
[LOG] 36.85478 file.qml:7: Any is undefined
----- Running table test 1: Read a nested field via a value (not pointer) in an interface -----
[LOG] 36.85478 file.qml:3: String is <content>
----- Running table test 2: Read a native property -----
----- Running table test 3: Read object properties -----
----- Running table test 4: Lowercasing of object properties -----
[LOG] 36.85478 file.qml:3: Names are <a> <b> <c> <d>
----- Running table test 5: No access to private fields -----
[LOG] 36.85478 file.qml:3: Private is undefined
----- Running table test 6: Set a custom property -----
[LOG] 36.85478 file.qml:6: file:////home/peter/go/src/gopkg.in/qml.v0/file.qml:6: TypeError: Cannot read property 'stringValue' of null
[LOG] 36.85478 file.qml:6: String is <content>
[LOG] 36.85478 file.qml:7: Width is 300
[LOG] 36.85478 file.qml:8: Height is 200
----- Running table test 7: Read and set a QUrl property -----
----- Running table test 8: Read and set a QColor property -----
----- Running table test 9: Read and set a QColor property from a Go field -----
[LOG] 36.85478 file.qml:3: #102040
----- Running table test 10: Read a QQmlListProperty property into a Go slice -----
----- Running table test 11: Read a QQmlListReference property into a Go slice -----
----- Running table test 12: Read a QVariantList property into a Go slice -----
----- Running table test 13: Set a Go slice property -----
----- Running table test 14: Set a Go slice property with objects -----
----- Running table test 15: Call a method with a JSON object (issue #48) -----
----- Running table test 16: Read a map from a QML property -----
----- Running table test 17: Identical values remain identical when possible -----
[LOG] 36.85478 file.qml:3: Identical: true
----- Running table test 18: Object finding via objectName -----
----- Running table test 19: Register Go type -----
[LOG] 36.85478 file.qml:3: String is <initial>
----- Running table test 20: Register Go type with an explicit name -----
[LOG] 36.85478 file.qml:3: String is <initial>
----- Running table test 21: Write Go type property -----
----- Running table test 22: Write Go type property that has a setter -----
----- Running table test 23: Write Go type property that has a setter and a getter -----
[LOG] 36.85478 file.qml:5: Getter returned <content>
----- Running table test 24: Write an inline object list to a Go type property -----
[LOG] 36.85478 file.qml:6: Length: 2
[LOG] 36.85478 file.qml:7: Name: on
----- Running table test 25: Write an inline object list to a Go type property that has a setter -----
----- Running table test 26: Clear an object list in a Go type property -----
----- Running table test 27: Clear an object list in a Go type property that has a setter -----
----- Running table test 28: Access underlying Go value with Interface -----
----- Running table test 29: Notification signals on custom Go type -----
----- Running table test 30: Singleton type registration -----
[LOG] 36.85478 file.qml:3: String is <initial>
----- Running table test 31: qml.Changed on unknown value is okay -----
----- Running table test 32: qml.Changed triggers a QML slot -----
[LOG] 36.85478 file.qml:5: String is <new>
[LOG] 36.85478 file.qml:6: String at addr is <new at addr>
----- Running table test 33: qml.Changed must not trigger on the wrong field -----
----- Running table test 34: qml.Changed updates bindings -----
----- Running table test 35: Call a Go method without arguments or result -----
[LOG] 36.85478 file.qml:3: Undefined is undefined
----- Running table test 36: Call a Go method with one argument and one result -----
[LOG] 36.85478 file.qml:3: String was <old>
----- Running table test 37: Call a Go method with multiple results -----
[LOG] 36.85478 file.qml:6: mod is 2 and err is undefined
----- Running table test 38: Call a Go method that returns an error -----
[LOG] 36.85478 file.qml:6: err is <division by zero>
----- Running table test 39: Call a Go method that recurses back into the GUI thread -----
[LOG] 36.85478 file.qml:6: Notification arrived
----- Running table test 40: Connect a QML signal to a Go method -----
----- Running table test 41: Call a QML method with no result or parameters from Go -----
[LOG] 36.85478 file.qml:3: f was called
----- Running table test 42: Call a QML method with result and parameters from Go -----
----- Running table test 43: Call a QML method with a custom type -----
[LOG] 36.85478 file.qml:3: String is <content>
----- Running table test 44: Call a QML method that returns a QML object -----
----- Running table test 45: Call a QML method that holds a custom type past the return point -----
[LOG] 36.85478 file.qml:6: String is <content>
----- Running table test 46: Call a non-existent QML method -----
----- Running table test 47: Ensure URL of provided file is correct by loading a local file -----
[LOG] 36.85478 file.qml:3: Ready: true
----- Running table test 48: Create window with non-window root object -----
----- Running table test 49: Create window with window root object -----
----- Running table test 50: Window is object -----
----- Running table test 51: Pass a *Value back into a method -----
[LOG] 36.85478 file.qml:3: Width is 300
----- Running table test 52: Create a QML-defined component in Go -----
----- Running table test 53: Call a Qt method that has no result -----
[LOG] 36.85478 file.qml:3: item destroyed
[LOG] 36.85478 file.qml:3: item destroyed
----- Running table test 54: Errors connecting to QML signals -----
----- Running table test 55: Connect to a QML signal without parameters -----
----- Running table test 56: Connect to a QML signal with a parameters -----
----- Running table test 57: Connect to a QML signal with an object parameter -----
----- Running table test 58: Load image from Go provider -----
[LOG] 36.85478 file.qml:5: Size: 200 100
----- Running table test 59: TypeName -----
----- Running table test 60: Custom Go type with painting -----
qml_test.go:1287:
    t.Done(&testData)
qml_test.go:1105:
    c.Assert(c.createdRect, HasLen, 1)
... obtained []*qml_test.GoRect = []*qml_test.GoRect(nil)
... n int = 1

OOPS: 9 passed, 1 FAILED
--- FAIL: Test (7.62 seconds)
FAIL
exit status 1
FAIL    gopkg.in/qml.v0 7.635s

When configuring for OSX 10.9.x (brew install qt5 --HEAD) QT5VERSION is incorrectly set

The following command doesn't work after "brew install qt5 --HEAD":

> QT5VERSION=`pkg-config --cflags Qt5Core | sed 's/^.*\(5\..\..\).*/\1/g'`

The output of pkg-config --cflags looks like this (no version number)

> echo $QT5VERSION
-I/usr/local/Cellar/qt5/HEAD/include/QtCore -I/usr/local/Cellar/qt5/HEAD/include

A better command is this:

> QT5VERSION=`pkg-config --modversion Qt5Core`

The output of pkg-config --modversion looks like:

>pkg-config --modversion Qt5Core
5.2.2

go get error

go get github.com/niemeyer/qml
can't load package: package github.com/niemeyer/qml: /home/kyle/go/bin/src/github.com/niemeyer/qml/bridge.go: invalid #cgo verb: #cgo CPPFLAGS: -I./cpp -I/usr/include/qt5/QtCore/5.0.2/QtCore -I/usr/include/qt5/QtCore/5.1.1/QtCore -I/usr/include/qt/QtCore/5.1.1/QtCore

Build error after commit e033ffcc21

I get this build error on windows/mingw compiler after commit e033ffc

In file included from .\all.cpp:2:0:
.\cpp/capi.cpp: In function 'void windowShow(QQuickWindow_*)':
.\cpp/capi.cpp:178:22: error: expected type-specifier before 'ShowWindow'
     reinterpret_cast<ShowWindow *>(win)->show();
                      ^
.\cpp/capi.cpp:178:22: error: expected '>' before 'ShowWindow'
.\cpp/capi.cpp:178:22: error: expected '(' before 'ShowWindow'
.\cpp/capi.cpp:178:34: error: expected primary-expression before '>' token
     reinterpret_cast<ShowWindow *>(win)->show();
                                  ^
.\cpp/capi.cpp:178:40: error: 'QQuickWindow_* {aka void*}' is not a pointer-to-object type
     reinterpret_cast<ShowWindow *>(win)->show();
                                        ^
.\cpp/capi.cpp:178:48: error: expected ')' before ';' token
     reinterpret_cast<ShowWindow *>(win)->show();
                                                ^

Mac OS bug: is only safe to invoke on the main thread

mac os 10.9.3
QT 5.2.1

github.com/go-qml/qml/examples/customtype

2014-05-23 01:41:40.054 customtype[44170:1b03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1056.13/Misc.subproj/NSUndoManager.m:328
2014-05-23 01:41:40.056 customtype[44170:1b03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2014-05-23 01:41:40.065 customtype[44170:1b03](0 CoreFoundation 0x00007fff96fb925c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff93a99e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff96fb9038 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff96b5cd41 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 Foundation 0x00007fff96ac728c +[NSUndoManager%28NSPrivate%29 _endTopLevelGroupings] + 156
5 AppKit 0x00007fff957ffa43 -[NSApplication run] + 688
6 libqcocoa.dylib 0x0000000007db95a5 _ZN21QCocoaEventDispatcher13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE + 2149
7 QtCore 0x0000000005a3345d _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE + 397
8 QtCore 0x0000000005a362e7 _ZN16QCoreApplication4execEv + 359
9 customtype 0x0000000004079c61 runtime.asmcgocall + 97)

Install dependencies on Ubuntu 12.04.4

Hi! I have failed to install ubuntu-sdk on Ubuntu 12.04.4, so:

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
sudo apt-get update
sudo apt-get install qtdeclarative5-dev qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev qtdeclarative5-qtquick2-plugin

After that Go QML compiles succesfully and all of the examples too. For Go installation I use GVM.

needs launchpad.net/gocheck

The install doc should mention it needs gocheck for running the tests, even though that can be inferred from the error message
all_test.go:8:2: cannot find package "launchpad.net/gocheck" in any of:

Can't find <private/qsgrendernode_p.h>

OSX 10.9.1 - Tried both with qt 5.2.0 and qt 5.2.2 (brew install --head)

In file included from /usr/local/gocode/src/github.com/niemeyer/qml/all.cpp:3:0:
/usr/local/gocode/src/github.com/niemeyer/qml/cpp/govalue.cpp:2:37: fatal error: private/qsgrendernode_p.h: No such file or directory
#include <private/qsgrendernode_p.h>

There is no file named qsgrender* in any of the QT include subdirectories.

error: comma at end of enumerator list [-pedantic]

On ubuntu 12.04 box.

$ go build

github.com/niemeyer/qml

In file included from /home/wiliam/devel/gocode/src/github.com/niemeyer/qml/cpp/govalue.h:9:0,
from /home/wiliam/devel/gocode/src/github.com/niemeyer/qml/cpp/capi.cpp:8,
from /home/wiliam/devel/gocode/src/github.com/niemeyer/qml/all.cpp:2:
/home/wiliam/devel/gocode/src/github.com/niemeyer/qml/cpp/capi.h:49:20: error: comma at end of enumerator list [-pedantic]

QVariantMap Support

I tried to pass an object to a Go function like follows:
game.createJob("walkto", false, {"x": tx, "y": ty})

However, the Go code fails to understand the passed object:
panic: unsupported variant type: 8 (QVariantMap)

Posting issue here as per request. If I get around to implementing it myself, I'll post the code up. However, I think it is unlikely. I'll probably try to press forward working on my application.

SIGCHILD handling in Mac OS

With this piece of code:

package main

import (
    "bytes"
    "github.com/niemeyer/qml"
    "log"
    "os/exec"
)

type tt struct{}

func (t *tt) Test() {
    log.Println("here")
    log.Println(exec.Command("echo", "hello").CombinedOutput())
    log.Println("But not here")
}

func main() {
    qml.Init(nil)
    engine := qml.NewEngine()
    engine.Context().SetVar("crash", &tt{})
    component, err := engine.Load("test.qml", bytes.NewReader([]byte(`
import QtQuick 2.0

Item {
    Component.onCompleted: crash.test()
}
`)))
    if err != nil {
        log.Fatalln(err)
    }

    component.Create(nil)

}

I get this output:

2013/12/26 15:07:38 here
fatal error: runtime: stack split during syscall

runtime stack:
runtime.throw(0x4299eac)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:462 +0x69
runtime.newstack()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/stack.c:261 +0x6cb
runtime.morestack()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:225 +0x61

goroutine 4 [stack split]:
syscall.Syscall6(0x7, 0xf68, 0xc2100001b0, 0x0, 0xc21005f360, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/syscall/asm_darwin_amd64.s:41 +0x5 fp=0x5ffc078
syscall.wait4(0xf68, 0xc2100001b0, 0x0, 0xc21005f360, 0x40450a2, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/syscall/zsyscall_darwin_amd64.go:32 +0x7d fp=0x5ffc0d8
syscall.Wait4(0xf68, 0x5ffc15c, 0x0, 0xc21005f360, 0xc21000a260, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/syscall/syscall_bsd.go:126 +0x6e fp=0x5ffc120
os.(*Process).wait(0xc21000a520, 0x0, 0x0, 0x0)
    /Users/quarnster/code/3rdparty/go/src/pkg/os/exec_unix.go:22 +0x10e fp=0x5ffc1b0
os.(*Process).Wait(0xc21000a520, 0x0, 0x0, 0x18)
    /Users/quarnster/code/3rdparty/go/src/pkg/os/doc.go:43 +0x27 fp=0x5ffc1d8
os/exec.(*Cmd).Wait(0xc210065140, 0x0, 0x0)
    /Users/quarnster/code/3rdparty/go/src/pkg/os/exec/exec.go:311 +0x1d9 fp=0x5ffc278
os/exec.(*Cmd).Run(0xc210065140, 0x4113220, 0x42a6e68)
    /Users/quarnster/code/3rdparty/go/src/pkg/os/exec/exec.go:233 +0x54 fp=0x5ffc298
os/exec.(*Cmd).CombinedOutput(0xc210065140, 0x4, 0x5ffc370, 0x1, 0x1, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/os/exec/exec.go:355 +0x279 fp=0x5ffc328
main.(*tt).Test(0x42a7080)
    /private/tmp/test.go:14 +0x19b fp=0x5ffc440
runtime.call16(0x4114070, 0xc2100000e8)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:338 +0x32 fp=0x5ffc458
reflect.Value.call(0x4113fe0, 0x42a7080, 0x0, 0x138, 0x4138320, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/reflect/value.go:614 +0x148c fp=0x5ffc990
reflect.Value.Call(0x4113fe0, 0x42a7080, 0x0, 0x138, 0xc210065000, ...)
    /Users/quarnster/code/3rdparty/go/src/pkg/reflect/value.go:451 +0xa5 fp=0x5ffc9f8
github.com/niemeyer/qml.hookGoValueCallMethod(0x6050f40, 0xc210046040, 0x7fff00000000, 0x7fff5fbfc7f0)
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/bridge.go:439 +0x460 fp=0x5ffcc98
----- stack segment boundary -----
runtime.cgocallbackg1()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:296 +0xbf fp=0x5ffcd70
runtime.cgocallbackg()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:266 +0x84 fp=0x5ffcd80
runtime.cgocallback_gofunc(0x402a5b3, 0x4001f00, 0x5ffcdf8)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:711 +0x67 fp=0x5ffcd90
runtime.asmcgocall(0x4001f00, 0x5ffcdf8)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:618 +0x2d fp=0x5ffcd98
runtime.cgocall(0x4001f00, 0x5ffcdf8)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x133 fp=0x5ffcde0
github.com/niemeyer/qml._Cfunc_componentCreate(0x612dfc0, 0x0, 0x5ffce38)
    /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/go-build434387843/github.com/niemeyer/qml/_obj/_cgo_defun.c:91 +0x31 fp=0x5ffcdf8
github.com/niemeyer/qml.func·022()
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/qml.go:614 +0x57 fp=0x5ffce20
github.com/niemeyer/qml.hookIdleTimer()
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/bridge.go:167 +0x5b fp=0x5ffce50
----- stack segment boundary -----
runtime.cgocallbackg1()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:296 +0xbf fp=0x5ffcf08
runtime.cgocallbackg()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:266 +0x84 fp=0x5ffcf18
runtime.cgocallback_gofunc(0x402a5b3, 0x4001d90, 0x5ffcf90)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:711 +0x67 fp=0x5ffcf28
runtime.asmcgocall(0x4001d90, 0x5ffcf90)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/asm_amd64.s:618 +0x2d fp=0x5ffcf30
runtime.cgocall(0x4001d90, 0x5ffcf90)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x133 fp=0x5ffcf78
github.com/niemeyer/qml._Cfunc_applicationExec(0x42af320)
    /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/go-build434387843/github.com/niemeyer/qml/_obj/_cgo_defun.c:73 +0x31 fp=0x5ffcf90
github.com/niemeyer/qml.guiLoop()
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/bridge.go:38 +0x5b fp=0x5ffcfa0
runtime.goexit()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1394 fp=0x5ffcfa8
created by github.com/niemeyer/qml.Init
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/qml.go:58 +0xac

goroutine 1 [chan receive]:
github.com/niemeyer/qml.gui(0xc21000a140)
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/bridge.go:66 +0xa3
github.com/niemeyer/qml.(*Common).Create(0xc210044300, 0x0, 0x1a, 0x6411190)
    /Users/quarnster/code/go/src/github.com/niemeyer/qml/qml.go:615 +0x123
main.main()
    /private/tmp/test.go:33 +0x2e0

goroutine 3 [syscall]:
runtime.goexit()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1394
exit status 2

Any ideas?

$ go version
go version devel +176779a4ebed Tue Dec 24 08:24:32 2013 -0800 darwin/amd64

panic running customtype.go on windows

When running customtype.go on windows I get following output:

I just tried running customtype.go on windows and I get an panic...

Text changed...
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b2aa]

runtime stack:
runtime.panic(0x4cf6c0, 0x60c338)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11

goroutine 4 [syscall]:
runtime.cgocall(0x487e4b, 0x3056d4)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/cgocall.c:149 +0x10c fp=0x3056c8
github.com/niemeyer/qml._Cfunc_objectGoAddr(0x25a7660, 0x13120358, 0x4b4240)
        C:/Users/THOMAS~1.PC1/AppData/Local/Temp/go-build936011503/github.com/niemeyer/qml/_obj/_cgo_defun.c:376 +0x33 fp=0x3056d4
github.com/niemeyer/qml.func┬╖016()
        c:/GoExt/src/github.com/niemeyer/qml/qml.go:384 +0x58 fp=0x3056f4github.com/niemeyer/qml.hookIdleTimer()
        c:/GoExt/src/github.com/niemeyer/qml/bridge.go:163 +0x53 fp=0x30570c
----- stack segment boundary -----
runtime.cgocallbackg1()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/cgocall.c:296 +0xb4 fp=0x305770
runtime.cgocallbackg()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/cgocall.c:266 +0x7a fp=0x305778
runtime.cgocallback_gofunc(0x403cb0, 0x48796b, 0x3057c4)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/asm_386.s:676 +0x57 fp=0x305788
runtime.asmcgocall(0x48796b, 0x3057c4)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/asm_386.s:584 +0x22 fp=0x30578c
runtime.cgocall(0x48796b, 0x3057c4)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/cgocall.c:149 +0x120 fp=0x3057b8
github.com/niemeyer/qml._Cfunc_applicationExec(0x6139a0)
        C:/Users/THOMAS~1.PC1/AppData/Local/Temp/go-build936011503/github.com/niemeyer/qml/_obj/_cgo_defun.c:61 +0x33 fp=0x3057c4
github.com/niemeyer/qml.guiLoop()
        c:/GoExt/src/github.com/niemeyer/qml/bridge.go:34 +0x54 fp=0x3057ccruntime.goexit()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/proc.c:1394 fp=0x3057d0
created by github.com/niemeyer/qml.Init
        c:/GoExt/src/github.com/niemeyer/qml/qml.go:58 +0x8c

goroutine 1 [chan receive]:
github.com/niemeyer/qml.gui(0x13129260)
        c:/GoExt/src/github.com/niemeyer/qml/bridge.go:62 +0x94
github.com/niemeyer/qml.(*Common).Interface(0x13120300, 0x0, 0x26c8c8)
        c:/GoExt/src/github.com/niemeyer/qml/qml.go:387 +0x93
main.run(0x0, 0x1)
        c:/Workspace/goqml/qml/examples/customtype/customtype.go:47 +0x120
main.main()
        c:/Workspace/goqml/qml/examples/customtype/customtype.go:10 +0x20

goroutine 3 [syscall]:
runtime.goexit()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist738819395/go/src/pkg/runtime/proc.c:1394
exit status 2

segvault: obj.Set("parent", win.Root()) when using ApplicationWindow

I get a segvault when try to add QML Objects to an ApplicationWindow from Go.
This can be recreated by modifying the rect.qml from the reparent example.

import QtQuick 2.0
import QtQuick.Window 2.0

ApplicationWindow {
    width: 640
    height: 480
    color: "black"
}

The segvault occurs when calling obj.Set("parent", win.Root())

func run() error {
    qml.Init(nil)

    engine := qml.NewEngine()

    base, err := engine.LoadFile("base.qml")
    if err != nil {
        return err
    }
    rect, err := engine.LoadFile("rect.qml")
    if err != nil {
        return err
    }

    win := base.CreateWindow(nil)
    obj := rect.Create(nil)

    obj.Set("parent", win.Root())

    win.Show()
    win.Wait()

    return nil
}

Here is a gdb backtrace. The program breaks when calling QQuickItem::parentItem() on the ApplicationWindow.

#0  0x00007ffff6e83780 in QQuickItem::parentItem() const () from /usr/lib/libQt5Quick.so.5
#1  0x00007ffff6e8ffc0 in QQuickItem::setParentItem(QQuickItem*) () from /usr/lib/libQt5Quick.so.5
#2  0x00007ffff6e91c89 in QQuickItem::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQt5Quick.so.5
#3  0x00007ffff6fac267 in ?? () from /usr/lib/libQt5Quick.so.5
#4  0x00007ffff59814fb in QMetaProperty::write(QObject*, QVariant const&) const () from /usr/lib/libQt5Core.so.5
#5  0x00007ffff59a56df in QObject::setProperty(char const*, QVariant const&) () from /usr/lib/libQt5Core.so.5
#6  0x0000000000422682 in objectSetProperty (object=0xb5d6b0, name=0x7fffd8000a80 "parent", value=<optimized out>)

Problem with native appearance

Hi! I've got a problem in Ubuntu 13.10. When i preview UI with qmlscene it looks fine -
2014-03-16 22 27 55
But when i build application with go-qml it looks strange -
2014-03-16 22 30 39

ObjectByName hangs on Ubuntu, works on Windows

When calling ObjectByName under Ubuntu 14.04 64-bit, it hangs. "test2" is never printed.
Under Windows 32 bit, it works.
Using the gopher sample and adding ObjectByName into Init function, it works, so I don't think it's related.

It seems to hang on RunMain's "guiFunc <- f".

Thank you.

gopher.qml:

import QtQuick 2.2
import GoExtensions 1.0

Gopher {
    id: gopher
    width: 600; height: 400

    MouseArea {
        objectName: "glSceneMouseArea"
        acceptedButtons: Qt.AllButtons

        anchors.fill: parent
    }
}

gopher.go

package main

import (
    "fmt"
    "gopkg.in/qml.v0"
    "os"
)

func main() {
    filename := "gopher.qml"
    if len(os.Args) == 2 {
        filename = os.Args[1]
    }
    if err := run(filename); err != nil {
        fmt.Fprintf(os.Stderr, "error: %v\n", err)
        os.Exit(1)
    }
}

func run(filename string) error {
    qml.Init(nil)
    engine := qml.NewEngine()

    qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
        Init: InitGopher,
    }})

    component, err := engine.LoadFile(filename)
    if err != nil {
        return err
    }

    win := component.CreateWindow(nil)

    win.Set("x", 560)
    win.Set("y", 320)
    win.Show()
    win.Wait()
    return nil
}

type Gopher struct {
    qml.Object
}

func InitGopher(g *Gopher, obj qml.Object) {
    g.Object = obj
    println("test1")
    mouseArea := obj.ObjectByName("glSceneMouseArea")
    println("test2")
    mouseArea.Int("width")
}

func (r *Gopher) Paint(p *qml.Painter) {
}

Better support for embedded types.

I have a struct with an embedded type. In QML, the access to the fields of the embedded type are only possible if given the full qualifier.

So my question is, whether it would be possible to support embedded types in a way that makes the example work.

Here is some example code:

go code:

type Person struct {
    LastName  string
    FirstName string
}

type SpecialPerson struct {
    Number string
    Person
}

qml code (with the commented out line instead, it works):

TextField {
    text: specialPerson.firstName
    //text: specialPerson.person.firstName
}

error message:

Unable to assign [undefined] to QString

OSX 10.9.1 Error: no such file or directory : '/QtCore'

~  go version 
go version go1.2 darwin/386
☁  ~  ls /usr/local/Cellar/qt5/HEAD/include/QtCore/ | grep '^5'
5.2.1
☁  ~  echo $PKG_CONFIG_PATH
/usr/local/opt/qt5/lib/pkgconfig

☁  ~  CXX=g++-4.8 go get github.com/niemeyer/qml
# github.com/niemeyer/qml
clang: error: no such file or directory: '/QtCore'

is there any path not configured ?

Windows Build Problem: ... qopenglversionfunctions.h:785:43: error: expected unqualified-id ...

Hi,

building under Linux was no problem.
But I'm struggling for a few days to try to build it under windows 7 with mingw.

Below is the error message I received.
I also tried with Qt 5.2.1; same error.

I don't know what to do now... :(
Any hints?

Thanks for the great work so far!
Cheers, Christopher

>go get gopkg.in/qml.v0
# gopkg.in/qml.v0
In file included from C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui/qopenglcontext.h:63:0,
                 from C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui/QtGui:32,
                 from C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtOpenGL/QtOpenGLDepends:3,
                 from C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtOpenGL/QtOpenGL:3,
                 from gopkg.in\qml.v0\cpp/govalue.cpp:3,
                 from gopkg.in\qml.v0\all.cpp:3:
C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui/qopenglversionfunctions.h:785:43: error: expected unqualified-id before ')' token
     void (QOPENGLF_APIENTRYP MemoryBarrier)(GLbitfield barriers);

Compiling Gopher Example on Mac

In order to get the Gopher example to build on Mac, I had to edit the provided gl.h, line 2059 from:
#include <GL/glext.h>

To,
#include "glext.h"

Which uses then, I presume, the glext.h provided with Go QML bindings.

After having done this, the Gopher example worked fine. I think I'm running Qt 5.2.1, a Mavericks targeted build, installed with Bew.

Need support for model interface to set on views

model-view objects like TableView has a model property which needs to be set. Now to feed the view from a proper dynamic model this should probably be a go interface that mimics the virtual functions in C++ class QAbstractItemModel.

Since all other model classes inherits from this C++ class, that's all that needs to be implemented. Convenience interfaces for specialized view like listview and tableview may be implemented purely in Go to make life it easier for the Go user.

For an introduction to the C++ model classes have a look here: http://qt-project.org/doc/qt-5.1/qtquick/qtquick-modelviewsdata-cppmodels.html

Now, the implementation of this is essential to be able to support GUIs with larger amounts of non static data. And it also gives a very clean cut between data and gui as the same data model could be visualized in many different ways without having to make any changes to the data model itself.

Unsupported framebuffer format.

Sometimes when running the Gopher example I get this error:

qopenglframebufferobject.cpp:353: QOpenGLFramebufferObject: Unsupported framebuffer format.

After, Paint get called, but there is no update on the screen.

Restarting the program just a few frames are drawn before the error is thrown. At that point, only restarting graphics driver (or Windows) helps.

I'm using 64-bit Windows 7 with nVidia Quadro FX 3500, latest available driver.

signal: segmentation fault before 'main.main'

This was on Go 1.2 Linux 64 debian sid. Both packages work in isolation. They do not like each other, not sure why.

// test2.go

package main

import (
"azul3d.org/v0/native/freetype"
"gopkg.in/v0/qml"
)

var a freetype.Font

func main() {
qml.Init(nil)
}

qml.Changed works only when the value really change

I'm trying to make a simple file manager with the qml package. I have this view at the moment, which displays a list of files:

import QtQuick 2.0
import QtQuick.Controls 1.1

ApplicationWindow {
    objectName: "mainWindow"
    title: "My Application"
    width: 800
    height: 600

    TableView {
        objectName: "fileView"
        TableViewColumn{ role: "Name"  ; title: "Name" ; width: 600 }
        TableViewColumn{ role: "Size" ; title: "Size" ; width: 200 }
        model: files.len
        itemDelegate: Item {
            Text {
                text: files.cell(styleData.row, styleData.column)
            }
            clip: true
        }
        width: 800
        height: 600
        selectionMode: 2
    }
}

From Go, when the model changes, I call qml.Changed(files, &files.Len). This works well if the number of files before and after is different, however it does not do anything if files.Len hasn't actually changed.

Is this expected behavior? If so, is there any other way to force the view to refresh based on the model?

Context.SetVar - panic: pre-allocated buffer size was wrong

I'm unable to pass a struct via Context.SetVar and access one of its fields in the QML. I've tried passing many different structs to SetVars and calling them from the QML in many ways.

panic: pre-allocated buffer size was wrong

goroutine 4 [running]:
runtime.panic(0x53e340, 0xc21000a300)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/niemeyer/qml.typeInfo(0x55d860, 0xc21001d5d0, 0x55d860)
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/datatype.go:304 +0x7fd
github.com/niemeyer/qml.wrapGoValue(0xc21001d540, 0x55d860, 0xc21001d5d0, 0x1, 0x0)
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/bridge.go:233 +0x40d
github.com/niemeyer/qml.packDataValue(0x55d860, 0xc21001d5d0, 0xc21000a2d0, 0xc21001d540, 0x7fe6a0e09c01)
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/datatype.go:106 +0x21a
github.com/niemeyer/qml.func·013()
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/qml.go:292 +0x84
github.com/niemeyer/qml.hookIdleTimer()
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/bridge.go:172 +0x5b
github.com/niemeyer/qml._Cfunc_applicationExec(0x8c1380)
github.com/niemeyer/qml/_obj/_cgo_defun.c:57 +0x31
github.com/niemeyer/qml.guiLoop()
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/bridge.go:41 +0x5b
created by github.com/niemeyer/qml.Init
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/qml.go:44 +0xa0

goroutine 1 [runnable]:
github.com/niemeyer/qml.gui(0xc21001d600)
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/bridge.go:68 +0xa3
github.com/niemeyer/qml.(*Context).SetVar(0xc21000a2a0, 0x57fd80, 0x5, 0x55d860, 0xc21001d5d0)
/home/eb/Dropbox/go/src/github.com/niemeyer/qml/qml.go:298 +0x10b
main.run(0x7fe6a0e09ed0, 0x2)
/home/eb/Dropbox/go/src/taq/taq.go:90 +0x19d
main.main()
/home/eb/Dropbox/go/src/taq/taq.go:73 +0x31b

goroutine 3 [syscall]:
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1394

exit status 2

the go -code is here:

type Cell struct {
num int
val string
pic string
}

func NewCell(num int) Cell {
return Cell{val: "",num:num,pic:"blank.png"}
}

cell01 := NewCell(1) 
engine.Context().SetVar("cell1", &cell01)

and the qml file:

Image {
         source: cell1.pic
         fillMode: Image.PreserveAspectFit
     }

Any ideas?

signal slot connection fail

I get a runtime panic when running the below code:

panic: object does not expose a "closeButtonClicked" signal

I got it to work fine in C++ with the same qml file.


package main

import (
"fmt"
"github.com/niemeyer/qml"
)

func main() {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadFile("qmltest2.qml")
if err != nil {
panic(err)
}

window := component.CreateWindow(nil)
component.On("closeButtonClicked", func() { fmt.Println("Close button was clicked") })

window.Show()
window.Wait()

}


import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0

Item {
id: root
width: 200
height: 200

signal closeButtonClicked()

ColumnLayout {
    anchors.fill: parent
    anchors.margins: 3
    spacing: 2
    Button {
        objectName: "mCloseButton"
        id: mCloseButton;
        text: qsTr("Close")
        anchors.horizontalCenter: parent.horizontalCenter
        onClicked: root.closeButtonClicked()
    }
}

}

[wishlist] qml.Changed function "update all fields"

Is it possible to expand qml.Changed to notify QML that all fields of a value has been changed. So far calling qml.Changed passing the address of the value is equivalent to notify that the first field of the struct has been changed (unplanned behaviour?).

Example:

[...]
mytext.Color = color.RGBA{n(), n(), n(), 0xff}
mytext.Text = "new text"
qml.Changed(mytext, &mytext.Text)
qml.Changed(mytext, &mytext.Color)
// instead of calling qml.Changed for each field it would be faster to
// just call qml.Changed(mytext, &mytext) or a function with a variadic
// parameter qml.Changed(mytext, &mytext.Text, &mytext.Color)
[...]

type Mytext struct {
    Text string
    Color color.RGBA
}

Go get fails on trusty with qt 5.2

cwayne@athena:~$ go get github.com/go-qml/qml
github.com/go-qml/qml
In file included from go/src/github.com/go-qml/qml/cpp/capi.cpp:10:0,
from go/src/github.com/go-qml/qml/all.cpp:2:
go/src/github.com/go-qml/qml/cpp/govalue.h:7:35: fatal error: private/qmetaobject_p.h: No such file or directory
#include <private/qmetaobject_p.h>

qt5-default:amd64 5.2.1+dfsg-1ubuntu7

private/qmetaobject_p.h: No such file or directory

go get -v -u github.com/niemeyer/qml
github.com/niemeyer/qml (download)
github.com/niemeyer/qml
# github.com/niemeyer/qml
In file included from src/github.com/niemeyer/qml/cpp/capi.cpp:10:0,
                 from src/github.com/niemeyer/qml/all.cpp:2:
src/github.com/niemeyer/qml/cpp/govalue.h:7:35: fatal error: private/qmetaobject_p.h: No such file or directory
 #include <private/qmetaobject_p.h>

OS: Archlinux 64 bits
QT version: 5.2.1 (I received an update today. It was ok with the previous version.)

Cannot "go get" on Debian Unstable

Debian Unstable purports to have a full Qt5 package set now. I installed qtbase5-private-dev and qtdeclarative5-private-dev along with everything else Qt5 and PyQt5 related that seems to be relevant, assuming the Debian dependencies will take care of everything. Sadly this appears to be not true, as I get:

|> go get github.com/niemeyer/qml

github.com/niemeyer/qml

In file included from ../../github.com/niemeyer/qml/cpp/capi.cpp:9:0,
from ../../github.com/niemeyer/qml/all.cpp:2:
../../github.com/niemeyer/qml/cpp/govalue.h:7:35: fatal error: private/qmetaobject_p.h: No such file or directory
#include <private/qmetaobject_p.h>
^
compilation terminated.

"fatal error: malloc/free - deadlock" when using x64 go/libs on windows

This was posted to the newsgroup, but I didn't see any issue for it here.

I'm using:

All the examples I tried would build successfully but give a stack trace similar to this when run:

D:\dev\gopath\src\github.com\niemeyer\qml\examples\particle>go build

D:\dev\gopath\src\github.com\niemeyer\qml\examples\particle>particle.exe
fatal error: malloc/free - deadlock
[signal 0xc0000005 code=0x0 addr=0x30 pc=0x41e56a]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fefda896cb
runtime.throw(0x632d60)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/panic.c:464 +0x74
runtime.mallocgc(0x10, 0x0, 0x0)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/malloc.goc:51 +0x57
runtime.mal(0x10)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/malloc.goc:700 +0x3b
copyin(0x4e3260, 0x22fb88, 0x22fba0)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/iface.c:153 +0x6a
runtime.convT2E(0x4e3260, 0x63180f, 0x31, 0x4e3260, 0x31)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/iface.c:221 +0x46
runtime.newErrorString(0x63180f, 0x31, 0x22fbd8)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/error.go:74 +0x3d
runtime.panicstring(0x63180f)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/panic.c:477 +0x94
runtime.sigpanic()
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/os_windows.c:337 +0xca
runtime.mallocgc(0x10, 0x0, 0x0)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/malloc.goc:70 +0xfa
runtime.mal(0x10)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/malloc.goc:700 +0x3b
copyin(0x4e3260, 0x22fd10, 0x22fd28)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/iface.c:153 +0x6a
runtime.convT2E(0x4e3260, 0x63180f, 0x31, 0x4e3260, 0x31)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/iface.c:221 +0x46
runtime.newErrorString(0x63180f, 0x31, 0x22fd60)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/error.go:74 +0x3d
runtime.panicstring(0x63180f)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/panic.c:477 +0x94
runtime: unexpected return pc for runtime.sigpanic called from 0x7fefda896cb
runtime.sigpanic()
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/os_windows.c:337 +0xca

goroutine 4 [syscall]:
runtime.cgocall(0x49bb72, 0x7ddf90)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/cgocall.c:149 +0x120 fp=0x7ddf78
github.com/niemeyer/qml._Cfunc_idleTimerInit(0x63ca9c)
    C:/Users/michael/AppData/Local/Temp/go-build834293743/github.com/niemeyer/qml/_obj/_cgo_defun.c:223 +0x34 fp=0x7ddf90
github.com/niemeyer/qml.guiLoop()
    D:/dev/gopath/src/github.com/niemeyer/qml/bridge.go:31 +0x48 fp=0x7ddfa0
runtime.goexit()
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/proc.c:1389 fp=0x7ddfa8
created by github.com/niemeyer/qml.Init
    D:/dev/gopath/src/github.com/niemeyer/qml/qml.go:58 +0xa3

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x63cadc)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/sema.goc:199 +0x33
sync.(*Mutex).Lock(0x63cad8)
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/sync/mutex.go:66 +0xd9
github.com/niemeyer/qml.Init(0x0)
    D:/dev/gopath/src/github.com/niemeyer/qml/qml.go:59 +0xb6
main.main()
    D:/dev/gopath/src/github.com/niemeyer/qml/examples/particle/main.go:10 +0x2c

goroutine 3 [syscall]:
runtime.goexit()
    C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist259766551/go/src/pkg/runtime/proc.c:1389

Let me know if I can provide anymore information.

statically link on osx

i try to pass in -static, but it shows a lot of libraries cannot be statically linked.
I wonder if anyone has the solution to link qt only

QML engine GCs resources after receiving reference

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

Can I staticly link Qt?

I'm new to cross-platform GUI development. How hard would it be to build statically linked applications for Linux, OS X, and Windows with one Go codebase? I really just want to be able to distribute a single binary with no dependencies.

doesn't install using go 1.1.2

It should probably be documented that the build
fails against go 1.1.2 with this error message:

% go get github.com/niemeyer/qml
package github.com/niemeyer/qml
imports github.com/niemeyer/qml
imports github.com/niemeyer/qml: /home/rog/src/go/src/github.com/niemeyer/qml/bridge.go: invalid #cgo verb: #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.0.2/QtCore -I./cpp

wrong goroutine in newstack

Platform is an Arch Linux 32-bit virtual machine (opengl 3d hardware acceleration is on and glxinfo confirms it is working). Running the following commands to set up dependencies and test the installation.

sudo pacman -S qt5 pkg-config
go get -u github.com/niemeyer/qml
cd $GOPATH/src/github.com/niemeyer/qml/examples/particle
GOTRACEBACK=2 go run main.go &> log

Basically, install dependencies and run the particle example. Go 1.2 is installed. (note to others: you may need to correct a typo in /usr/share/X11/locale/en_US.UTF8/Compose from "actute" to "acute", otherwise you get a keysym error.) go get succeeds without incident so it looks like all the headers are in place.

Then go run results in this log: https://gist.github.com/tummychow/9046195
Haven't seen anything like this in previous issues. Suggestions?

QML Init causes panic

qml.Init(nil) call, on Arch Linux (with qt 5.2 or 5.1)

Package was downloaded and installed today.

2014/02/16 00:59:39 qtablegenerator.cpp:451: "Qt Warning - invalid keysym: dead_actute"
panic: pre-allocated buffer size was wrong

goroutine 12 [running]:
runtime.panic(0x85eba0, 0xc2100d2790)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/niemeyer/qml.typeInfo(0x903e60, 0xc210050040, 0x903e60)
/home/phil/go/src/github.com/niemeyer/qml/datatype.go:304 +0x7fd
github.com/niemeyer/qml.wrapGoValue(0xc2100da000, 0x903e60, 0xc210050040, 0x1, 0x0)
/home/phil/go/src/github.com/niemeyer/qml/bridge.go:233 +0x40d
github.com/niemeyer/qml.packDataValue(0x903e60, 0xc210050040, 0xc2100d26b0, 0xc2100da000, 0x7fa2c0c6ec01)
/home/phil/go/src/github.com/niemeyer/qml/datatype.go:106 +0x21a
github.com/niemeyer/qml.func·013()
/home/phil/go/src/github.com/niemeyer/qml/qml.go:292 +0x84
github.com/niemeyer/qml.hookIdleTimer()
/home/phil/go/src/github.com/niemeyer/qml/bridge.go:172 +0x5b
github.com/niemeyer/qml._Cfunc_applicationExec(0xf9ebf8)
github.com/niemeyer/qml/_obj/_cgo_defun.c:57 +0x31
github.com/niemeyer/qml.guiLoop()
/home/phil/go/src/github.com/niemeyer/qml/bridge.go:41 +0x5b
created by github.com/niemeyer/qml.Init
/home/phil/go/src/github.com/niemeyer/qml/qml.go:44 +0xa0

Handle struct values (non-pointer)

Occurs in both v0 and v1:

package qml_test

import (
    "gopkg.in/qml.v1"
    "testing"
)

func init() {
    qml.SetupTesting()
}

func TestBlah(t *testing.T) {
    //qml.Init(nil)
    type Blah struct {
        A int
    }

    f := func() error {
        e := qml.NewEngine()
        defer e.Destroy()
        e.Context().SetVar("blah", Blah{})
        c, err := e.LoadString("blah.qml", `
import QtQuick 2.0
Item {
    Component.onCompleted: {
        blah.a = 10;
    }
}
`)
        if err != nil {
            return err
        }
        w := c.CreateWindow(nil)
        defer w.Destroy()
        return nil
    }
    err := f()
    if err != nil {
        t.Error(err)
    }
}

Yes I understand that it goes away if I do e.Context().SetVar("blah", &Blah{}), but that is besides the point.

Real use case is a go function that returns a small struct type by value. This value I then want to modify qml side to pass on this modified data to another go function.

qt5.21 minwg error:panic: invalid memory address or nil pointer dereference

env:

F:\baiduyun\backup\gopath\src\gopkg.in\v0\qml\examples\customtype>go env
set GOARCH=386
set GOBIN=
set GOCHAR=8
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=F:\baiduyun\backup\gopath
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_386
set TERM=dumb
set CC=gcc
set GOGCCFLAGS=-g -O2 -m32 -mthreads
set CXX=g++
set CGO_ENABLED=1

error for all examples:

F:\baiduyun\backup\gopath\src\gopkg.in\v0\qml\examples\customtype>go run customt
ype.go
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b8ea]

runtime stack:
runtime.panic(0x4f17c0, 0x66c56f)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/r
untime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x749af4fc

goroutine 4 [syscall]:
runtime.cgocall(0x48b47b, 0x3d57c4)
C:/Users/ADMINI1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/r
untime/cgocall.c:149 +0x10c fp=0x3d57b8
gopkg.in/v0/qml._Cfunc_idleTimerInit(0x674090)
C:/Users/ADMINI
1/AppData/Local/Temp/go-build364249083/gopkg.in/v0/qml/_
obj/_cgo_defun.c:229 +0x33 fp=0x3d57c4
gopkg.in/v0/qml.guiLoop()
F:/baiduyun/backup/gopath/src/gopkg.in/v0/qml/bridge.go:38 +0x41 fp=0x3d
57cc
runtime.goexit()
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/r
untime/proc.c:1394 fp=0x3d57d0
created by gopkg.in/v0/qml.Init
F:/baiduyun/backup/gopath/src/gopkg.in/v0/qml/qml.go:44 +0x8c

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x6740cc)
C:/Users/ADMINI1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/r
untime/sema.goc:199 +0x33
sync.(*Mutex).Lock(0x6740c8)
C:/Users/ADMINI
1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/s
ync/mutex.go:66 +0xcd
gopkg.in/v0/qml.Init(0x0)
F:/baiduyun/backup/gopath/src/gopkg.in/v0/qml/qml.go:45 +0x9c
main.run(0x1, 0xffffffff)
F:/baiduyun/backup/gopath/src/gopkg.in/v0/qml/examples/customtype/custom
type.go:30 +0x2a
main.main()
F:/baiduyun/backup/gopath/src/gopkg.in/v0/qml/examples/customtype/custom
type.go:10 +0x20

goroutine 3 [syscall]:
runtime.goexit()
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/r
untime/proc.c:1394
exit status 2

F:\baiduyun\backup\gopath\src\gopkg.in\v0\qml\examples\customtype>

Turn panics into javascript exceptions?

Would it be possible to catch panic's and convert them into a javascript exception instead?

This is mostly with #68 in mind where the panic originates in go-qml before it reaches "my" code, but it got me thinking that it'd be nice if any panics occuring in my code would also be converted into a javascript exception when the initiating call originates from a QML file.

Can't find OpenGL on OSX 10.5.1

On OSX the OpenGL library is in a framework, so the "common" -lGL doesn't work.
This should fix the problem:

diff --git a/bridge.go b/bridge.go
index 3846217..629a810 100644
--- a/bridge.go
+++ b/bridge.go
@@ -10,7 +10,8 @@ package qml
// #cgo CPPFLAGS: -I/usr/include/qt/QtCore/5.1.1/QtCore
// #cgo CPPFLAGS: -I/usr/include/qt/QtQuick/5.1.1/QtQuick
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing -DGL_GLEXT_PROTOTYPES
-// #cgo LDFLAGS: -lstdc++ -lGL
+// #cgo !darwin LDFLAGS: -lstdc++ -lGL
+// #cgo darwin LDFLAGS: -lstdc++ -framework OpenGL
// #cgo pkg-config: Qt5Core Qt5Widgets Qt5Quick Qt5OpenGL
//
// #include <stdlib.h>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.