[webkit-qt] QtRuntimeObject problem
Kang Liu
tomsheep.cn at gmail.com
Thu Sep 8 20:17:53 PDT 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20110909/2298bc16/attachment.html>
More information about the webkit-qt
mailing list