Code review comment for lp:~gerboland/unity-api/surfaceSizerCallback

Revision history for this message
Gerry Boland (gerboland) wrote :

> > I tried:
> >
> > Binding {
> > target: ApplicationManager
> > property: "surfaceAboutToBeCreatedCallback"
> > value: function surfaceSizer(surface) { print("Hihi")
> > surface.width = 400;
> > if (surface.appId && surface.appId == "dialer-app") {
> > surface.height = 300;
> > }
> > return surface;
> > }
> > }
> >
> > and got this error:
> > file:///usr/share/unity8/Stages/PhoneStage.qml:125:12: Unable to assign a
> function to a property of any type other than var.
>
> Hah! Interesting. Can't say I understand. If Binding.value is of type
> other than var, how can it be flexible enough? Otherwise if
> ApplicationManager.surfaceAboutToBeCreatedCallback is not var, how would
> your original approach to assign instead of bind work in any case?
>
> I'd say that's worth a QTBUG.

My guess is that Binding does some naive type checking, and QJSValue is indeed not a QVariant. qtdeclarative5:/src/qml/qml/qmlproperty.cpp does confirm that idea: http://pastebin.ubuntu.com/8099923/ - I don't understand why exactly..

I don't create a binding with my original approach, it's a simple assignment. I would guess the only way around this error is to replace QJSValue with a QVariant. What say you?

« Back to merge proposal