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

QML problems with Qt 5.7 #551

Closed
bgr opened this issue Jul 27, 2016 · 3 comments
Closed

QML problems with Qt 5.7 #551

bgr opened this issue Jul 27, 2016 · 3 comments

Comments

@bgr
Copy link

bgr commented Jul 27, 2016

Hey, QML problems have come up again.

They've changed something in Qt 5.7 (and maybe 5.6 as well, I skipped that version). Running this minimal example:

// example.qml
import QtQuick 2.7
import "sugar.js" as Sugar

Item {
    Component.onCompleted: {
        Sugar.Sugar.extend();
    }
}

causes the following error: sugar.js:798: TypeError: Type error

(of course, the exact line will vary depending on the build, this one is from the QML build from today's master; the same error happens with regular downloaded sugar.js build as well as the months-old and proven QML build I've been using so far)

I briefly inspected what's going on, seems like it's due to undefined being passed as arg to sugarNamespace.extend(arg); up in the call stack, but I might be wrong.

To run the example you can download Qt 5.7 here and run it using qmlscene example.qml (assumed that "sugar.js" file is in the same directory; qmlscene binary can be found in e.g. .../Qt/Qt5.7.0/5.7/<compiler>/bin)

@andrewplummer
Copy link
Owner

Well, it would appear that an update to QML has made native all native methods configurable: false, meaning that any attempt to override them results in a TypeError. Sugar 1.4.1 does this to allow enhanced Array methods. Sugar 2.0.0 does it as well, however in making native extension opt-in, this issue was anticipated, so fortunately you can just do this:

// example.qml
import QtQuick 2.7
import "sugar.js" as Sugar

Item {
    Component.onCompleted: {
        Sugar.Sugar.extend({
          enhance: false
        });
    }
}

This should take care of the issue for you. Overriding native methods being controversial as it is, this flag was added. However, the changes QML have instituted are not part of spec, and could potentially interfere with polyfills, so should be treated as a bug. Maybe filing a bug report would make sense?

@bgr
Copy link
Author

bgr commented Aug 1, 2016

Thanks. I've filed the issue.

The enhance: false fix looks promising, the impact seems relatively small. I'll keep this issue open for now, other Qt-related problems might come out once I fix this one.

@andrewplummer
Copy link
Owner

Essentially what it means is that you won't be able to take advantage of enhanced methods. At the moment this is essentially just shortcuts for every, filter, map, etc.

Note however, that the "enhanced" functionality will still work with the new static methods or chainables, so you can still take advantage of it there.

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