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're not interested in it anymore.
return False
win = QApplication.instance().activeWindow()
if win is None:
return False
if win.objectName() != 'MainWindow':
if (QApplication.instance().activeWindow() not in
objreg.window_registry.values()):
# Some other window (print dialog, etc.) is focused so we pass
# the event through.
return False

View File

@ -115,19 +115,22 @@ def _get_tab_registry():
raise RegistryUnavailableError('tab')
def _get_window_registry(win_id):
def _get_window_registry(window):
"""Get the registry of a window."""
if win_id is None:
raise TypeError("win_id is None with scope window!")
if win_id == 'current':
if window is None:
raise TypeError("window is None with scope window!")
if window is 'current':
app = get('app')
win = app.activeWindow()
if win is None or not hasattr(win, 'win_id'):
raise RegistryUnavailableError('window')
else:
win_id = win.win_id
else:
try:
win = window_registry[window]
except KeyError:
raise RegistryUnavailableError('window')
try:
return window_registry[win_id]
return win.registry
except AttributeError:
raise RegistryUnavailableError('window')
@ -196,7 +199,8 @@ def dump_objects():
blocks = []
lines = []
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()))
# FIXME: Add tab registries
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):
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._commandrunner = None
self.win_id = win_id
registry = objreg.ObjectRegistry()
objreg.window_registry[win_id] = registry
self.registry = objreg.ObjectRegistry()
objreg.window_registry[win_id] = self
objreg.register('main-window', self, scope='window', window=win_id)
message_bridge = message.MessageBridge(self)