Fix segfault closing client after starting it without network access.

* src/client/conversation-list/conversation-list-view.vala
  (ConversationListView): Convert to using IdleManager for handling
  selection updating, reset it when widget is destroyed.
This commit is contained in:
Michael James Gratton 2017-02-09 10:56:45 +11:00
parent 31fbfd4047
commit c1fb400e24

View file

@ -18,7 +18,7 @@ public class ConversationListView : Gtk.TreeView {
private Geary.Scheduler.Scheduled? scheduled_update_visible_conversations = null;
private Gtk.Menu? context_menu = null;
private Gee.Set<Geary.App.Conversation> selected = new Gee.HashSet<Geary.App.Conversation>();
private uint selection_changed_id = 0;
private Geary.IdleManager selection_update;
private bool suppress_selection = false;
public signal void conversations_selected(Gee.Set<Geary.App.Conversation> selected);
@ -35,6 +35,7 @@ public class ConversationListView : Gtk.TreeView {
public signal void visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible);
public ConversationListView() {
set_show_expanders(false);
set_headers_visible(false);
@ -69,6 +70,14 @@ public class ConversationListView : Gtk.TreeView {
unowned Gtk.BindingSet? binding_set = Gtk.BindingSet.find("GtkTreeView");
assert(binding_set != null);
Gtk.BindingEntry.remove(binding_set, Gdk.Key.N, Gdk.ModifierType.CONTROL_MASK);
this.selection_update = new Geary.IdleManager(do_selection_changed);
this.selection_update.priority = Geary.IdleManager.Priority.LOW;
}
public override void destroy() {
this.selection_update.reset();
base.destroy();
}
public new ConversationListStore? get_model() {
@ -365,9 +374,6 @@ public class ConversationListView : Gtk.TreeView {
}
private void on_selection_changed() {
if (this.selection_changed_id != 0)
Source.remove(this.selection_changed_id);
// Schedule processing selection changes at low idle for
// two reasons: (a) if a lot of changes come in
// back-to-back, this allows for all that activity to
@ -377,13 +383,7 @@ public class ConversationListView : Gtk.TreeView {
// order by this class and the ConversationListView and
// not result in a lot of screen flashing and (again)
// unnecessary I/O as both classes update selection state.
this.selection_changed_id = Idle.add(() => {
// De-schedule the callback
this.selection_changed_id = 0;
do_selection_changed();
return Source.REMOVE;
}, Priority.LOW);
this.selection_update.schedule();
}
// Gtk.TreeSelection can fire its "changed" signal even when