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

Qt 5.4 panic: unsupported variant type: 1024 (QJSValue) #137

Open
obscuren opened this issue Jan 4, 2015 · 5 comments
Open

Qt 5.4 panic: unsupported variant type: 1024 (QJSValue) #137

obscuren opened this issue Jan 4, 2015 · 5 comments

Comments

@obscuren
Copy link

obscuren commented Jan 4, 2015

Using QT 5.4.0 with qml v1 and exporting the following object:

type MyObject struct {}
func (m *MyObject) Call(m map[string]interface{}) {
    fmt.Println(m)
}
context.SetVar("m", &MyObject{})
// m.call( {} );

Will result in: panic: unsupported variant type: 1024 (QJSValue)

Possible solution
On https://github.com/go-qml/qml/blob/v1/cpp/capi.cpp#L725 add a case QMetaType::User:

@obscuren
Copy link
Author

After doing some testing the above possible solution didn't turn out to work properly.

I've updated it with the following (and will send a proper PR once fully tested)

case QMetaType::User:
    {
        if (qvar->userType() == 1034)
        {
            auto var = qvar->value<QJSValue>().toVariant();
            packDataValue(&var, value);
        }
        else
        {
            qDebug() << "user-type =" << qvar->userType() << " name =" << QVariant::typeToName(qvar->userType());
        }
    }
    break;

I've left the qDebug in for debugging purposes (hasn't occurred yet after some testing). I also couldn't find a proper constant for 1034 (i.e. QJSValue).

@obscuren
Copy link
Author

Created PR, see #140

@janimo
Copy link

janimo commented Aug 2, 2015

I see this error when trying to pass a Javascript array to a function on an object exported from Go.

@janimo
Copy link

janimo commented Aug 2, 2015

The diff from the PR fixes it for me.

@bcampbell
Copy link

Just to add, I've been seeing the same error, when passing a javascript array out from QML to a go function on Qt 5.4.2.
But I don't know where it crept in exactly, as I did a go get -u on go-qml and upgraded from Qt5.2 at the same time...

Anyway, PR #140 also fixed it for me.

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

3 participants