[webkit-qt] QtRuntimeObject problem

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Fri Sep 9 02:39:07 PDT 2011


Hi Kang Liu
That's the current behavior. JS properties assigned to Qt objects are not persistent.
It might be worthwhile to fix that in the docs; feel free to post a bug in bugs.webkit.org or to submit a patch.

No'am
________________________________________
From: webkit-qt-bounces at lists.webkit.org [webkit-qt-bounces at lists.webkit.org] On Behalf Of ext Kang Liu [tomsheep.cn at gmail.com]
Sent: Thursday, September 08, 2011 8:17 PM
To: webkit-qt at lists.webkit.org
Subject: [webkit-qt]  QtRuntimeObject problem

Hi,

I am using QtWebkit in my product, and yesterday I got a strange problem.
I tyied to Inject objects into javascript environment in this way:

There are two QObjects I want to injcect, named "A" and "B", and A is the parent of B.
QObject *A = ...
QObject *B = ...
B->setParent(A);
A->setObjectName("A");
B->setObjectName("B");
QWebFrame *frame = ... // the target frame
connect(frame, SIGNAL(javaScriptWindowObjectCleared()),this, SLOT(Inject()));

And in Inject slot:

frame->addToJavaScriptWindowObject(A->objectName(), A);
QString js("A.B.foo = 'bar';");
frame->evaluateJavaScript(js);

Then the strange thing happens, I can access A.B.foo successfully at first time, but if I do some other operations, for example,
invoke the web inspector or close another window in my app(which has no business with current window), then the A.B.foo is gone! But A.B is still there,
 and all INVOKABLE methods and properties are still accessible.

I am not sure whether it is a bug, the Qt version is 4.7.3.


--
Best Regards
- Kang Liu


More information about the webkit-qt mailing list