Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectByName hangs on Ubuntu, works on Windows #63

Closed
neclepsio opened this issue Apr 28, 2014 · 1 comment
Closed

ObjectByName hangs on Ubuntu, works on Windows #63

neclepsio opened this issue Apr 28, 2014 · 1 comment

Comments

@neclepsio
Copy link

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) {
}
@niemeyer
Copy link
Contributor

This is not just ObjectByName, but about how the rendering thread in QML runs with the main thread blocked. This was already handled in a different scenario, but something seems to be missing. I'll get it fixed, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants