[Qtscript-bindings] QScriptValue::isFunction() in 4.5
Kent Hansen
khansen at trolltech.com
Tue Jan 6 11:47:27 CET 2009
syntheticpp at gmx.net wrote:
> Thanks for the quick answer Kent.
>
> But maybe there is a bug in the handling of 'instanceof'.
> With the Qt patch below my script works again:
>
> @@ -1294,7 +1294,7 @@ Ltop:
> QScriptValueImpl object = stackPtr[-1];
> QScriptValueImpl ctor = stackPtr[0];
>
> - if (!ctor.isObject() || !ctor.implementsHasInstance()) {
> + if (!ctor.isQObject() && (!ctor.isObject() || !ctor.implementsHasInstance())) {
> stackPtr -= 2;
> throwTypeError(QLatin1String("invalid 'instanceof' operand"));
> HandleException();
>
>
> Doesn't QObject implement hasInstance()?
>
> Peter
>
>
Right, QObject doesn't implement hasInstance(). Of the built-in object
types only Function implements hasInstance(). With Qt 4.5 you can
implement it for custom types (see
http://doc.trolltech.com/main-snapshot/qscriptclass.html#extension).
It sounds like your script is applying the instanceof operator to an
object created with QScriptEngine::newQObject(). I'm sorry that it
breaks now, but it should never have been working in the first place.
:-( Maybe you can share some more information on what the script is
doing, then it's easier to suggest a proper solution.
Regards,
Kent
More information about the Qtscript-bindings
mailing list