Commit 99225107 authored by bbbw's avatar bbbw Committed by Marinus Schraal

searchview: Fix crash in FlowBox allocations

If a search is performed and allocation occurs and hides some results,
the 'visible' property of the widget in the FlowBox will be assigned
False. However, when a new search is performed, this property is not
updated to True, but the old value is kept. So, if the search results
for artist or albums happen to overlap with previously hidden results,
then last_child in _on_artist_flowbox_size_allocate() and
last_visible_child in _on_album_flowbox_size_allocate() can be None,
which will cause a crash.

To fix this, every time a new search is triggered all FlowBox widgets
set 'visible' to True.

Fixes #372
parent fb3f4232
......@@ -199,6 +199,11 @@ class SearchView(Gtk.Stack):
nr_albums = self._album_model.get_n_items()
self._view_all_albums.props.visible = (nr_albums > model.get_n_items())
def set_child_visible(child):
child.props.visible = True
self._album_flowbox.foreach(set_child_visible)
def _on_artist_model_items_changed(self, model, position, removed, added):
items_found = model.get_n_items() > 0
self._artist_header.props.visible = items_found
......@@ -209,6 +214,11 @@ class SearchView(Gtk.Stack):
self._view_all_artists.props.visible = (
nr_artists > model.get_n_items())
def set_child_visible(child):
child.props.visible = True
self._artist_flowbox.foreach(set_child_visible)
def _on_model_items_changed(self, model, position, removed, added):
items_found = model.get_n_items() > 0
self._songs_header.props.visible = items_found
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment