Check the validity of an item before querying its tooltip

In case data() does not handle invalid items.
This commit is contained in:
Guillaume Munch 2016-12-03 23:35:15 +01:00
parent 03a0e983bc
commit 851ed60e49

View File

@ -52,6 +52,8 @@ bool ToolTipFormatter::eventFilter(QObject * o, QEvent * e)
// on the screen.
QPoint pos = static_cast<QHelpEvent *>(e)->pos();
QModelIndex item = iv->indexAt(pos);
if (!item.isValid())
return false;
QVariant data = iv->model()->data(item, Qt::ToolTipRole);
if (data.isValid() && data.typeName() == toqstr("QString"))
// Unchanged if empty or already formatted