[Qtscript-bindings] QScriptValue::isFunction() in 4.5

Kent Hansen khansen at trolltech.com
Tue Jan 6 09:13:51 CET 2009


Hi Peter,

syntheticpp at gmx.net wrote:
> Hello,
>
> I have a qtscript binding of Qt classes which work fine with Qt 4.4
> but are not usable with Qt4.5, qtscript warns:
>
> invalid 'instanceof' operand
>
> I've tracked it down to a different behaviour of QScriptValue::isFunction() const
> which returns true for 4.4 and false for 4.5:
>
> inline bool QScriptValueImpl::isFunction() const
> {
>     return (m_type == QScript::ObjectType)
>         && (classInfo()->type() & QScriptClassInfo::FunctionBased);
> }
>
>
> The reason is a changed enum value:
>
> class QScriptClassInfo
> {
> public:
>     enum Type {
>         FunctionBased   = 0x40000000,
>
>         ObjectType      = 1,
> ...
>
> Qt 4.4:
>         QObjectType     = 11 | FunctionBased,
> Qt 4.5:
>         QObjectType     = 11,
>
>
>
> Is this a Qt regression or my fault?
>
> Peter
>   


It's a fix for this task:
http://trolltech.com/developer/task-tracker/index_html?id=217781&method=entry
Normal QObject wrappers should never have been reporting to be function
objects; that was just a hack that unfortunately trickled up to the
public behavior.
QScriptEngine::newFunction() can be used to create function objects.

Regards,
Kent


More information about the Qtscript-bindings mailing list