Trying to join a room with a not connected account leads to crash (#603393).
EmpathyTpRoomlist *room_list;
/* Currently selected account */
TpAccount *account;
EmpathyTpRoomlist *room_list;
/* Currently selected account */
TpAccount *account;
+ /* Signal id of the "status-changed" signal connected on the currently
+ * selected account */
+ gulong status_changed_id;
GtkWidget *window;
GtkWidget *vbox_widgets;
GtkWidget *window;
GtkWidget *vbox_widgets;
g_object_unref (dialog->model);
if (dialog->account != NULL) {
g_object_unref (dialog->model);
if (dialog->account != NULL) {
+ g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
g_object_unref (dialog->account);
}
g_object_unref (dialog->account);
}
update_join_button_sensitivy (EmpathyNewChatroomDialog *dialog)
{
const gchar *room;
update_join_button_sensitivy (EmpathyNewChatroomDialog *dialog)
{
const gchar *room;
+ gboolean sensitive = FALSE;
+
room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
- gtk_widget_set_sensitive (dialog->button_join, !EMP_STR_EMPTY (room));
+ if (EMP_STR_EMPTY (room))
+ goto out;
+
+ if (dialog->account == NULL)
+ goto out;
+
+ if (tp_account_get_connection_status (dialog->account, NULL) !=
+ TP_CONNECTION_STATUS_CONNECTED)
+ goto out;
+
+ sensitive = TRUE;
+
+out:
+ gtk_widget_set_sensitive (dialog->button_join, sensitive);
gtk_widget_grab_focus (dialog->entry_room);
}
gtk_widget_grab_focus (dialog->entry_room);
}
+static void
+account_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ EmpathyNewChatroomDialog *self)
+{
+ update_join_button_sensitivy (self);
+}
+
static void
new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog)
static void
new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog)
new_chatroom_dialog_model_clear (dialog);
if (dialog->account != NULL) {
new_chatroom_dialog_model_clear (dialog);
if (dialog->account != NULL) {
+ g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
g_object_unref (dialog->account);
}
g_object_unref (dialog->account);
}
if (dialog->account == NULL)
goto out;
if (dialog->account == NULL)
goto out;
+ dialog->status_changed_id = g_signal_connect (dialog->account,
+ "status-changed", G_CALLBACK (account_status_changed_cb), dialog);
+
dialog->room_list = empathy_tp_roomlist_new (dialog->account);
if (dialog->room_list) {
dialog->room_list = empathy_tp_roomlist_new (dialog->account);
if (dialog->room_list) {