Use object registry for cache/cookiejar.
This commit is contained in:
parent
3b3675d1af
commit
ca2be960df
@ -61,8 +61,6 @@ class Application(QApplication):
|
||||
cmd_history: The "cmd_history" LineConfigParser instance.
|
||||
messagebridge: The global MessageBridge instance.
|
||||
modeman: The global ModeManager instance.
|
||||
cookiejar: The global CookieJar instance.
|
||||
cache: The global DiskCache instance.
|
||||
rl_bridge: The ReadlineBridge being used.
|
||||
args: ArgumentParser instance.
|
||||
_commandrunner: The main CommandRunner instance.
|
||||
@ -131,9 +129,11 @@ class Application(QApplication):
|
||||
log.init.debug("Initializing utility commands...")
|
||||
utilcmds.init()
|
||||
log.init.debug("Initializing cookies...")
|
||||
self.cookiejar = cookies.CookieJar(self)
|
||||
cookiejar = cookies.CookieJar(self)
|
||||
self.obj.register('cookiejar', cookiejar)
|
||||
log.init.debug("Initializing cache...")
|
||||
self.cache = cache.DiskCache(self)
|
||||
diskcache = cache.DiskCache(self)
|
||||
self.obj.register('cache', diskcache)
|
||||
log.init.debug("Initializing commands...")
|
||||
self._commandrunner = runners.CommandRunner()
|
||||
log.init.debug("Initializing search...")
|
||||
@ -756,8 +756,12 @@ class Application(QApplication):
|
||||
to_save.append(("command history", self.cmd_history.save))
|
||||
if hasattr(self, 'stateconfig'):
|
||||
to_save.append(("window geometry", self.stateconfig.save))
|
||||
if hasattr(self, 'cookiejar'):
|
||||
to_save.append(("cookies", self.cookiejar.save))
|
||||
try:
|
||||
cookiejar = self.obj.get('cookiejar')
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
to_save.append(("cookies", cookiejar.save))
|
||||
for what, handler in to_save:
|
||||
log.destroy.debug("Saving {} (handler: {})".format(
|
||||
what, handler.__qualname__))
|
||||
|
@ -51,13 +51,17 @@ class NetworkManager(QNetworkAccessManager):
|
||||
self._scheme_handlers = {
|
||||
'qute': qutescheme.QuteSchemeHandler(),
|
||||
}
|
||||
|
||||
# We have a shared cookie jar and cache - we restore their parents so
|
||||
# we don't take ownership of them.
|
||||
app = QCoreApplication.instance()
|
||||
self.setCookieJar(app.cookiejar)
|
||||
self.setCache(app.cache)
|
||||
# We have a shared cookie jar and cache , so we don't want the
|
||||
# NetworkManager to take ownership of them.
|
||||
app.cookiejar.setParent(app)
|
||||
app.cache.setParent(app)
|
||||
cookiejar = utils.get_object('cookiejar')
|
||||
self.setCookieJar(cookiejar)
|
||||
cookiejar.setParent(app)
|
||||
cache = utils.get_object('cache')
|
||||
self.setCache(cache)
|
||||
cache.setParent(app)
|
||||
|
||||
if SSL_AVAILABLE:
|
||||
self.sslErrors.connect(self.on_ssl_errors)
|
||||
self.authenticationRequired.connect(self.on_authentication_required)
|
||||
|
@ -388,6 +388,10 @@ class ObjectRegistry:
|
||||
"""A registry of long-living objects in qutebrowser.
|
||||
|
||||
Inspired by the eric IDE code (E5Gui/E5Application.py).
|
||||
|
||||
Objects registered globally:
|
||||
cookiejar: CookieJar instance.
|
||||
cache: DiskCache instance.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user