Stop potential crash by guarding the access to the page.

Based on the work from Shawn Krisman (krisman.shawn@gmail.com).

http://code.google.com/p/phantomjs/issues/detail?id=719
1.8
Ariya Hidayat 2012-09-24 07:28:05 -07:00
parent 63e06cbcbf
commit 8ba3c52d50
1 changed files with 6 additions and 0 deletions

View File

@ -315,6 +315,9 @@ QObject* Phantom::createCallback()
void Phantom::loadModule(const QString &moduleSource, const QString &filename)
{
if (m_terminated)
return;
QString scriptSource =
"(function(require, exports, module) {" +
moduleSource +
@ -328,6 +331,9 @@ void Phantom::loadModule(const QString &moduleSource, const QString &filename)
bool Phantom::injectJs(const QString &jsFilePath)
{
if (m_terminated)
return false;
return Utils::injectJsInFrame(jsFilePath, libraryPath(), m_page->mainFrame());
}