summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@digia.com>2012-12-06 14:06:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-06 16:18:55 +0100
commit2e9b46553049d2bcdd244a1908ada3a5faeac073 (patch)
treec5507e126616a81a03393690aa8903a22fc83b56 /examples
parent11a7354c9e14ba30dd4504e85ce5c736db3528e0 (diff)
downloadqtwebkit-examples-2e9b46553049d2bcdd244a1908ada3a5faeac073.tar.gz
Fix FancyBrowser crash caused by recursion loops.
Using jQuery iterators can cause recursion loops crash when converting the result set of the call to a QVariant because nextSibling, parentNode and previousSibling are all enumerable properties and hence get visited in the conversion to QVariantMap. The workaround is to append "; undefined" to the evaluated JavaScript to prevent that the whole iterator set is returned and converted. Task-number: QTBUG-28378 Change-Id: I92fb43ed823e34a9f68eb2904b0128b656115d74 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/webkit/fancybrowser/mainwindow.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp
index f540368..da6b070 100644
--- a/examples/webkit/fancybrowser/mainwindow.cpp
+++ b/examples/webkit/fancybrowser/mainwindow.cpp
@@ -167,7 +167,10 @@ void MainWindow::finishLoading(bool)
//! [7]
void MainWindow::highlightAllLinks()
{
- QString code = "$('a').each( function () { $(this).css('background-color', 'yellow') } )";
+ // We append '; undefined' after the jQuery call here to prevent a possible recursion loop and crash caused by
+ // the way the elements returned by the each iterator elements reference each other, which causes problems upon
+ // converting them to QVariants.
+ QString code = "$('a').each( function () { $(this).css('background-color', 'yellow') } ); undefined";
view->page()->mainFrame()->evaluateJavaScript(code);
}
//! [7]
@@ -176,10 +179,14 @@ void MainWindow::highlightAllLinks()
void MainWindow::rotateImages(bool invert)
{
QString code;
+
+ // We append '; undefined' after each of the jQuery calls here to prevent a possible recursion loop and crash caused by
+ // the way the elements returned by the each iterator elements reference each other, which causes problems upon
+ // converting them to QVariants.
if (invert)
- code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(180deg)') } )";
+ code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(180deg)') } ); undefined";
else
- code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(0deg)') } )";
+ code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(0deg)') } ); undefined";
view->page()->mainFrame()->evaluateJavaScript(code);
}
//! [8]