Skip to content

Commit 8a243d3

Browse files
committedAug 7, 2016
gui/applets: hack completer model to block noxious dataChanged signal. Closes #464
1 parent 84f4725 commit 8a243d3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎artiq/gui/applets.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,21 @@ def createEditor(self, parent, option, index):
275275
QtWidgets.QCompleter.CaseSensitivelySortedModel)
276276
completer.setCompletionRole(QtCore.Qt.DisplayRole)
277277
if hasattr(self, "model"):
278-
completer.setModel(self.model)
278+
# "TODO: Optimize updates in the source model"
279+
# - Qt (qcompleter.cpp), never ceasing to disappoint.
280+
# HACK:
281+
# In the meantime, block dataChanged signals from the model.
282+
# dataChanged never changes the content of the QCompleter in our
283+
# case, but causes unnecessary flickering and trashing of the user
284+
# selection when datasets are modified due to Qt's naive handler.
285+
# Doing this is of course convoluted due to Qt's arrogance
286+
# about private fields and not letting users knows what
287+
# slots are connected to signals, but thanks to the complicated
288+
# model system there is a short dirty hack in this particular case.
289+
nodatachanged_model = QtCore.QIdentityProxyModel()
290+
nodatachanged_model.setSourceModel(self.model)
291+
completer.setModel(nodatachanged_model)
292+
nodatachanged_model.dataChanged.disconnect()
279293
return _AutoCompleteEdit(parent, completer)
280294

281295
def set_model(self, model):

0 commit comments

Comments
 (0)
Please sign in to comment.