mirror of
https://github.com/encounter/phantomjs.git
synced 2026-03-30 11:35:11 -07:00
Create FileSystem instance only when needed.
Also made FileSystem a singleton.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user