Revert "Store window registries in objreg."

This reverts commit dfd3b3d9c4.

It turns out this makes it very hard to remove the window from the window
registry at the right time.
This commit is contained in:
Florian Bruhin 2014-10-05 23:09:35 +02:00
parent 180d6e45ef
commit d3121034df
3 changed files with 16 additions and 18 deletions

View File

@ -359,10 +359,8 @@ class ModeManager(QObject):
# We already handled this same event at some point earlier, so # We already handled this same event at some point earlier, so
# we're not interested in it anymore. # we're not interested in it anymore.
return False return False
win = QApplication.instance().activeWindow() if (QApplication.instance().activeWindow() not in
if win is None: objreg.window_registry.values()):
return False
if win.objectName() != 'MainWindow':
# Some other window (print dialog, etc.) is focused so we pass # Some other window (print dialog, etc.) is focused so we pass
# the event through. # the event through.
return False return False

View File

@ -115,19 +115,22 @@ def _get_tab_registry():
raise RegistryUnavailableError('tab') raise RegistryUnavailableError('tab')
def _get_window_registry(win_id): def _get_window_registry(window):
"""Get the registry of a window.""" """Get the registry of a window."""
if win_id is None: if window is None:
raise TypeError("win_id is None with scope window!") raise TypeError("window is None with scope window!")
if win_id == 'current': if window is 'current':
app = get('app') app = get('app')
win = app.activeWindow() win = app.activeWindow()
if win is None or not hasattr(win, 'win_id'): if win is None or not hasattr(win, 'win_id'):
raise RegistryUnavailableError('window') raise RegistryUnavailableError('window')
else: else:
win_id = win.win_id try:
win = window_registry[window]
except KeyError:
raise RegistryUnavailableError('window')
try: try:
return window_registry[win_id] return win.registry
except AttributeError: except AttributeError:
raise RegistryUnavailableError('window') raise RegistryUnavailableError('window')
@ -196,7 +199,8 @@ def dump_objects():
blocks = [] blocks = []
lines = [] lines = []
blocks.append(('global', global_registry.dump_objects())) blocks.append(('global', global_registry.dump_objects()))
for win_id, registry in window_registry.items(): for win_id in window_registry:
registry = _get_registry('window', window=win_id)
blocks.append(('window-{}'.format(win_id), registry.dump_objects())) blocks.append(('window-{}'.format(win_id), registry.dump_objects()))
# FIXME: Add tab registries # FIXME: Add tab registries
for name, data in sorted(blocks, key=lambda e: e[0]): for name, data in sorted(blocks, key=lambda e: e[0]):

View File

@ -72,15 +72,11 @@ class MainWindow(QWidget):
def __init__(self, win_id, parent=None): def __init__(self, win_id, parent=None):
super().__init__(parent) super().__init__(parent)
# Note the objectname is used in the event filter to filter keypresses
# not intended for the mainwindow. If this is changed, the event filter
# needs to be changed as well!
self.setObjectName('MainWindow')
self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_DeleteOnClose)
self._commandrunner = None self._commandrunner = None
self.win_id = win_id self.win_id = win_id
registry = objreg.ObjectRegistry() self.registry = objreg.ObjectRegistry()
objreg.window_registry[win_id] = registry objreg.window_registry[win_id] = self
objreg.register('main-window', self, scope='window', window=win_id) objreg.register('main-window', self, scope='window', window=win_id)
message_bridge = message.MessageBridge(self) message_bridge = message.MessageBridge(self)