Skip to content
Browse files

gui: Fix crash when quickly opening/closing applets

Quickly closing/reopening applets (e.g. quickly clicking the checkbox
on an entire folder of applets) would previously lead to an occasional
KeyError on the self.dock_to_item access in on_dock_closed, as close()
would be invoked more than once.

The geometry/checked state handling can potentially be cleaned up
further, but at least this avoid the crash.
  • Loading branch information...
dnadlinger authored and sbourdeauducq committed Mar 10, 2019
1 parent 6113ecb commit 01213e23813fdf31e2d643d1c97cbdc0cf6e419b
Showing with 6 additions and 10 deletions.
  1. +6 −10 artiq/gui/
@@ -321,7 +321,6 @@ def __init__(self, main_window, datasets_sub):

self.main_window = main_window
self.datasets_sub = datasets_sub
self.dock_to_item = dict()
self.applet_uids = set()

self.table = QtWidgets.QTreeWidget()
@@ -414,12 +413,12 @@ def set_spec(self, item, spec):

def create(self, uid, name, spec):
dock = _AppletDock(self.datasets_sub, uid, name, spec)
def create(self, item, name, spec):
dock = _AppletDock(self.datasets_sub, item.applet_uid, name, spec)
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
dock.sigClosed.connect(partial(self.on_dock_closed, dock))
dock.sigClosed.connect(partial(self.on_dock_closed, item, dock))
return dock

def item_changed(self, item, column):
@@ -437,15 +436,15 @@ def item_changed(self, item, column):
if item.applet_dock is None:
name = item.text(0)
spec = self.get_spec(item)
dock = self.create(item.applet_uid, name, spec)
dock = self.create(item, name, spec)
item.applet_dock = dock
if item.applet_geometry is not None:
# geometry is now handled by main window state
item.applet_geometry = None
self.dock_to_item[dock] = item
dock = item.applet_dock
item.applet_dock = None
if dock is not None:
# This calls self.on_dock_closed
@@ -455,12 +454,9 @@ def item_changed(self, item, column):
raise ValueError

def on_dock_closed(self, dock):
item = self.dock_to_item[dock]
item.applet_dock = None
def on_dock_closed(self, item, dock):
item.applet_geometry = dock.saveGeometry()
del self.dock_to_item[dock]
item.setCheckState(0, QtCore.Qt.Unchecked)

def get_untitled(self):

0 comments on commit 01213e2

Please sign in to comment.
You can’t perform that action at this time.