Fix crash when toggling an account very fast (#1505)

- The switch widget in the account managment
            dialog is now not accepting input while the account
            being enabled is connecting.
This commit is contained in:
Miquel Lionel 2024-06-16 21:15:52 +02:00 committed by Max Logaev
parent e55207c46e
commit c0299480ad

View file

@ -197,6 +197,7 @@ public class Dialog : Gtk.Dialog {
} }
private void populate_grid_data(Account account) { private void populate_grid_data(Account account) {
active_switch.sensitive = false;
active_switch.state_set.disconnect(change_account_state); active_switch.state_set.disconnect(change_account_state);
picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(new Conversation(account.bare_jid, account, Conversation.Type.CHAT), account.bare_jid); picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(new Conversation(account.bare_jid, account, Conversation.Type.CHAT), account.bare_jid);
@ -227,11 +228,14 @@ public class Dialog : Gtk.Dialog {
ConnectionManager.ConnectionState state = stream_interactor.connection_manager.get_state(account); ConnectionManager.ConnectionState state = stream_interactor.connection_manager.get_state(account);
switch (state) { switch (state) {
case ConnectionManager.ConnectionState.CONNECTING: case ConnectionManager.ConnectionState.CONNECTING:
active_switch.sensitive = false;
state_label.label = _("Connecting…"); break; state_label.label = _("Connecting…"); break;
case ConnectionManager.ConnectionState.CONNECTED: case ConnectionManager.ConnectionState.CONNECTED:
active_switch.sensitive = true;
password_change_btn.sensitive = true; password_change_btn.sensitive = true;
state_label.label = _("Connected"); break; state_label.label = _("Connected"); break;
case ConnectionManager.ConnectionState.DISCONNECTED: case ConnectionManager.ConnectionState.DISCONNECTED:
active_switch.sensitive = true;
password_change_btn.sensitive = false; password_change_btn.sensitive = false;
state_label.label = _("Disconnected"); break; state_label.label = _("Disconnected"); break;
} }