From e93bea5a2137172aca79a384801259f2b2975b9b Mon Sep 17 00:00:00 2001 From: IceArmy Date: Tue, 31 May 2011 23:17:50 -0700 Subject: [PATCH] Fix bug where script wouldn't exit properly --- python/phantom.py | 3 +++ python/pyphantomjs.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/phantom.py b/python/phantom.py index af8821e6..ea0f2f61 100644 --- a/python/phantom.py +++ b/python/phantom.py @@ -40,6 +40,7 @@ class Phantom(QObject): self.m_verbose = args.verbose self.m_page = WebPage(self) self.m_returnValue = 0 + self.m_terminated = False # setup the values from args self.m_script = args.script self.m_scriptFile = args.script_name @@ -89,6 +90,7 @@ class Phantom(QObject): self.m_script = coffee.convert(self.m_script) self.m_page.mainFrame().evaluateJavaScript(self.m_script) + return not self.m_terminated def printConsoleMessage(self, msg): print msg @@ -118,6 +120,7 @@ class Phantom(QObject): @pyqtSlot() @pyqtSlot(int) def exit(self, code=0): + self.m_terminated = True self.m_returnValue = code QApplication.instance().exit(code) diff --git a/python/pyphantomjs.py b/python/pyphantomjs.py index 80267d76..8c6e8d74 100644 --- a/python/pyphantomjs.py +++ b/python/pyphantomjs.py @@ -148,8 +148,8 @@ def main(): do_action('Main', Bunch(locals())) - phantom.execute() - app.exec_() + if phantom.execute(): + app.exec_() return phantom.returnValue()