Create FileSystem instance only when needed.

Also made FileSystem a singleton.
This commit is contained in:
IceArmy
2011-09-09 00:52:49 -07:00
parent 6bba1715df
commit 7bb97fb0da
2 changed files with 7 additions and 3 deletions
+6
View File
@@ -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)
+1 -3
View File
@@ -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):