Fixed issue #586. Valentina crashes if clear input filter string.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-11-10 11:15:52 +02:00
parent 91d43c4b26
commit c4b9346021

View File

@ -561,6 +561,18 @@ void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter)
{ {
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
// If filter is empty findItems() for unknown reason returns nullptr items.
// See issue #586. https://bitbucket.org/dismine/valentina/issues/586/valentina-crashes-if-clear-input-filter
if (filter.isEmpty())
{
// show all rows
for (auto i = 0; i < ui->tableWidget->rowCount(); ++i)
{
ui->tableWidget->showRow(i);
}
}
else
{
// hide all rows // hide all rows
for (auto i = 0; i < ui->tableWidget->rowCount(); i++) for (auto i = 0; i < ui->tableWidget->rowCount(); i++)
{ {
@ -569,9 +581,14 @@ void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter)
// show rows with matched filter // show rows with matched filter
for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains))
{
// If filter is empty findItems() for unknown reason returns nullptr items.
if (item)
{ {
ui->tableWidget->showRow(item->row()); ui->tableWidget->showRow(item->row());
} }
}
}
ui->tableWidget->blockSignals(false); ui->tableWidget->blockSignals(false);
} }