diff --git a/python/pyphantomjs/filesystem.py b/python/pyphantomjs/filesystem.py index 376ac458..4703c222 100644 --- a/python/pyphantomjs/filesystem.py +++ b/python/pyphantomjs/filesystem.py @@ -111,6 +111,12 @@ class File(QObject): class FileSystem(QObject): + _instance = None + def __new__(cls, *args, **kwargs): + if cls._instance is None: + cls._instance = super(CSConverter, cls).__new__(cls, *args, **kwargs) + return cls._instance + def __init__(self, parent): QObject.__init__(self, parent) diff --git a/python/pyphantomjs/phantom.py b/python/pyphantomjs/phantom.py index 1608228a..bd5fd200 100644 --- a/python/pyphantomjs/phantom.py +++ b/python/pyphantomjs/phantom.py @@ -52,8 +52,6 @@ class Phantom(QObject): self.m_scriptEncoding = Encode(args.script_encoding, 'utf-8') self.m_outputEncoding = Encode(args.output_encoding, sys.stdout.encoding_sys) - self.m_filesystem = FileSystem(self) - self.m_pages.append(self.m_page) do_action('PhantomInitPre') @@ -120,7 +118,7 @@ class Phantom(QObject): @pyqtSlot(result=FileSystem) def createFilesystem(self): - return self.m_filesystem + return FileSystem(self) @pyqtSlot(result=WebPage) def createWebPage(self):