QAbstractItemView: warn in some erroneous conditions
If a user or a delegate asks a view to act on an editor that does not belong to the view, report a warning instead of silently ignoring the problem. This erroneous condition can happen for instance if a user installs the same delegate on multiple views (something that the documentation says _not_ to do) and the delegate indeed emits signals related to the editors of one view -- the other views don't know about that editor. Change-Id: I2d10582ebb7aefca4acea306b8a57bcc3162050a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f02879a97a
commit
6625a4744e
@ -2936,8 +2936,10 @@ void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndE
|
||||
bool isPersistent = d->persistent.contains(editor);
|
||||
bool hadFocus = editor->hasFocus();
|
||||
QModelIndex index = d->indexForEditor(editor);
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
qWarning("QAbstractItemView::closeEditor called with an editor that does not belong to this view");
|
||||
return; // the editor was not registered
|
||||
}
|
||||
|
||||
// start a timer that expires immediately when we return to the event loop
|
||||
// to identify whether this close was triggered by a mousepress-initiated
|
||||
@ -3015,8 +3017,10 @@ void QAbstractItemView::commitData(QWidget *editor)
|
||||
if (!editor || !d->itemDelegate || d->currentlyCommittingEditor)
|
||||
return;
|
||||
QModelIndex index = d->indexForEditor(editor);
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
qWarning("QAbstractItemView::commitData called with an editor that does not belong to this view");
|
||||
return;
|
||||
}
|
||||
d->currentlyCommittingEditor = editor;
|
||||
QAbstractItemDelegate *delegate = itemDelegateForIndex(index);
|
||||
editor->removeEventFilter(delegate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user