[Qt-qml] Function in QScriptValue can only be called for a short time
Kent Hansen
kent.hansen at nokia.com
Thu Feb 10 18:34:30 CET 2011
Hi,
Den 10. feb. 2011 13:36, skrev ext Ville M. Vainio:
> I am using QScriptValue to store a javascript function. I have a C++
> method that stores it aside for later use:
>
>
> void Deferred::onRes(const QScriptValue&v)
> {
> m_res = v;
>
> // m_res.call()); THIS WOULD WORK
> }
>
> - If I invoke call() as in the snippet above, in comments, the
> function is called alright.
> - If I invoke call() from the same QML method that called onRes, the
> call works as well
>
> - HOWEVER, if I invoke it even later (on some signal handler), the
> function doesn't get called.
>
> m_res.toString() shows the correct function body in all cases. It's as
> if the link to script engine got broken somehow?
>
> Any idea what "spoils" the QScriptValue in this fashion? I have tried
> to ensure that nothing gets garbage collected, so I don't think that's
> the cause.
>
If you post a self-contained example that demonstrates the issue,
someone might figure out what's going on.
Regards,
Kent
More information about the Qt-qml
mailing list