Fixed issue #586. Valentina crashes if clear input filter string.
--HG-- branch : develop
This commit is contained in:
parent
91d43c4b26
commit
c4b9346021
|
@ -561,16 +561,33 @@ void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter)
|
||||||
{
|
{
|
||||||
ui->tableWidget->blockSignals(true);
|
ui->tableWidget->blockSignals(true);
|
||||||
|
|
||||||
// hide all rows
|
// If filter is empty findItems() for unknown reason returns nullptr items.
|
||||||
for (auto i = 0; i < ui->tableWidget->rowCount(); i++)
|
// See issue #586. https://bitbucket.org/dismine/valentina/issues/586/valentina-crashes-if-clear-input-filter
|
||||||
|
if (filter.isEmpty())
|
||||||
{
|
{
|
||||||
ui->tableWidget->hideRow(i);
|
// show all rows
|
||||||
|
for (auto i = 0; i < ui->tableWidget->rowCount(); ++i)
|
||||||
|
{
|
||||||
|
ui->tableWidget->showRow(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// show rows with matched filter
|
|
||||||
for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains))
|
|
||||||
{
|
{
|
||||||
ui->tableWidget->showRow(item->row());
|
// hide all rows
|
||||||
|
for (auto i = 0; i < ui->tableWidget->rowCount(); i++)
|
||||||
|
{
|
||||||
|
ui->tableWidget->hideRow(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// show rows with matched filter
|
||||||
|
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->blockSignals(false);
|
ui->tableWidget->blockSignals(false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user