Fix web-history-max-items-crash.
Fixes #2849, where pressing 'o' with web-history-max-items set and no history items would cause a crash as the query result is empty.
This commit is contained in:
parent
630e9ebd66
commit
2ad4cdd729
@ -72,6 +72,10 @@ class HistoryCategory(QSqlQueryModel):
|
|||||||
'ORDER BY last_atime DESC LIMIT :limit)',
|
'ORDER BY last_atime DESC LIMIT :limit)',
|
||||||
])).run(limit=max_items).value()
|
])).run(limit=max_items).value()
|
||||||
|
|
||||||
|
if not min_atime:
|
||||||
|
# if there are no history items, min_atime may be '' (issue #2849)
|
||||||
|
return ''
|
||||||
|
|
||||||
return "AND last_atime >= {}".format(min_atime)
|
return "AND last_atime >= {}".format(min_atime)
|
||||||
|
|
||||||
def set_pattern(self, pattern):
|
def set_pattern(self, pattern):
|
||||||
|
@ -126,7 +126,8 @@ def test_set_pattern(pattern, before, after, model_validator, hist):
|
|||||||
], [
|
], [
|
||||||
('b', 'b', '2017-06-16'),
|
('b', 'b', '2017-06-16'),
|
||||||
('c', 'c', '2017-05-16'),
|
('c', 'c', '2017-05-16'),
|
||||||
])
|
]),
|
||||||
|
(1, [], []), # issue 2849 (crash with empty history)
|
||||||
])
|
])
|
||||||
def test_sorting(max_items, before, after, model_validator, hist, config_stub):
|
def test_sorting(max_items, before, after, model_validator, hist, config_stub):
|
||||||
"""Validate the filtering and sorting results of set_pattern."""
|
"""Validate the filtering and sorting results of set_pattern."""
|
||||||
|
Loading…
Reference in New Issue
Block a user