Fix empty filters in project files

Fix loading of project files with empty filter values. If an empty
filter value was saved in a project file, it did not show up in the UI
but was partially added to the query anyway. This lead to an invalid
query with no results.

Also fix a possible loophole which at least in theory could lead to an
empty filter value being stored in the project file.

See issue #2288.
This commit is contained in:
Martin Kleusberg
2020-06-19 10:35:46 +02:00
parent f7e593a8a4
commit 60f121434c
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -2320,7 +2320,9 @@ static void loadBrowseDataTableSettings(BrowseDataTableSettings& settings, QXmlS
while(xml.readNext() != QXmlStreamReader::EndElement && xml.name() != "filter_values") {
if (xml.name() == "column") {
size_t index = xml.attributes().value("index").toUInt();
settings.filterValues[index] = xml.attributes().value("value").toString();
QString value = xml.attributes().value("value").toString();
if(!value.isEmpty())
settings.filterValues[index] = value;
xml.skipCurrentElement();
}
}
+3 -2
View File
@@ -525,9 +525,10 @@ void TableBrowser::updateFilter(size_t column, const QString& value)
// Save the new filter settings
BrowseDataTableSettings& settings = m_settings[currentlyBrowsedTableName()];
if(value.isEmpty() && settings.filterValues.erase(column) > 0)
if(value.isEmpty())
{
emit projectModified();
if(settings.filterValues.erase(column) > 0)
emit projectModified();
} else {
if (settings.filterValues[column] != value) {
settings.filterValues[column] = value;