Fix bug where WebPage.evaluate had a syntax error.

It now creates a proper anonymous function (which passes this for global context)
1.2
IceArmy 2011-06-01 02:09:07 -07:00
parent 0d78768e4d
commit d2c520a777
2 changed files with 2 additions and 2 deletions

View File

@ -269,7 +269,7 @@ class WebPage(QObject):
@pyqtSlot(str, result='QVariant')
def evaluate(self, code):
function = '(%s)()' % code
function = '(function(){%s}).call(this);' % code
return self.m_mainFrame.evaluateJavaScript(function)
@pyqtSlot(str, str, 'QVariantMap')

View File

@ -209,7 +209,7 @@ QVariantMap WebPage::paperSize() const
QVariant WebPage::evaluate(const QString &code)
{
QString function = "(" + code + ")()";
QString function = "(function(){" + code + "}).call(this);";
return m_mainFrame->evaluateJavaScript(function);
}