RFC --- new scripting extension sketches.

koos vriezen koos.vriezen at gmail.com
Sat May 15 22:21:33 BST 2010


2010/5/12 Maksim Orlovich <mo85 at cornell.edu>:
> <snip>
> OK, I went ahead and committed a new version of this extension. I've also
> ported KHTML to it, and provided a backwards compatibility adapter that
> bridges things that implement LiveConnectExtension to the new interface.

Awesome work!
Small nitpick is maybe a constructor for Object/FunctionRef that takes
all members to make QVariant::setValue an one liner (be it a long
line).

> Thus far, nspluginviewer seems to work fine, as do the basic methods in
> kmplayer -- unfortunately it doesn't want to launch knnplayer for me for
> some reason.

Odd, seem to work fine for me.

> Unfortunately, though, I am out of gas, so I don't think I can port
> nspluginviewer due to the freeze (though perhaps branching it might make
> sense, just to test everything), so the test coverage is kind of, well,
> awful.
>
> Koos, do you have any nice testcases for flash scripting stuff? And
> anyway, it would be pretty cool if kmplayer could take advantage of
> this... though I suppose it has backwards compatibility with old KDE
> versions to worry about.

I went ahead with a simple Play/Stop function support for any media.
It works, but only because I don't need object live time tracking for
this. The issue I see is when calling 'embedId.Play(), with this as
debug output:

rootObject
acquire 0
KMPlayerScriptableExtension::get 0 Play
acquire 1
release 0
callAsFunction
callMediaFunction
release 1

Now the call to 'rootObject' returns object with Id 0 and the 'get'
for function 'Play', returns objId 1. Objects returned should have
refCount set to 1, to make it not initial unowned, since the callee
can't deref the object after returning it. So all objects received by
khtml are acquired incorrectly (should be not acquired or released
twice).

At least that is my understanding of it. Here how I implemented the
function that evaluates a script in the host browser:

    KParts::ScriptableExtension* host = m_scriptableextension->host ();
    if (host) {
        QVariant embed = m_scriptableextension->enclosingObject ();
        if (embed.canConvert <KParts::ScriptableExtension::Object> ()) {
            quint64 id = embed.value
<KParts::ScriptableExtension::Object> ().objId;
            QVariant result = host->evaluateScript
(m_scriptableextension, id, script);
            host->release (id);
            return result.toString ();
        }
    }
    return "undefined";

As you can see, I only released the enclosing object.


Koos




More information about the kfm-devel mailing list