Commit 36a316be authored by Jiří Klimeš's avatar Jiří Klimeš
Browse files

eap: use G_DEFINE_BOXED_TYPE to simplify code and be thread-safe (rh #979123)

inner_auth_combo_changed_cb():
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
  gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
  g_assert (eap);

gtk_combo_box_get_model() failed and thus g_assert (eap) failed as well.

On some circumstances type_id resets to 0 in eap_method_get_g_type(). It makes
g_boxed_type_register_static() be called again, which results in failing
assertion 'g_type_form_name (name) == 0' and thus eap_method_get_g_type()
returns 0 instead of proper GType. Later using 0 make gtk_list_store_new()
fail to get proper GListStore:
inner_auth_combo_init:
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ())

Even if this patch is right, the problem is not solved, because instead of
the crash a deadlock may occur. It might be the same issue as described in
https://bugzilla.gnome.org/show_bug.cgi?id=674885.

https://bugzilla.redhat.com/show_bug.cgi?id=979123
parent f1d3307f
......@@ -253,7 +253,7 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
if (s_wireless_sec)
default_type = get_default_type_for_security (s_wireless_sec);
sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_g_type (), G_TYPE_BOOLEAN);
sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_type (), G_TYPE_BOOLEAN);
if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
gtk_list_store_append (sec_model, &iter);
......
......@@ -864,7 +864,7 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only)
wep_type = NM_WEP_KEY_TYPE_PASSPHRASE;
}
sec_model = gtk_list_store_new (2, G_TYPE_STRING, wireless_security_get_g_type ());
sec_model = gtk_list_store_new (2, G_TYPE_STRING, wireless_security_get_type ());
if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) {
gtk_list_store_append (sec_model, &iter);
......
......@@ -241,7 +241,7 @@ inner_auth_combo_init (EAPMethodFAST *method,
guint32 active = 0;
const char *phase2_auth = NULL;
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ());
if (s_8021x) {
if (nm_setting_802_1x_get_phase2_auth (s_8021x))
......
......@@ -244,7 +244,7 @@ inner_auth_combo_init (EAPMethodPEAP *method,
guint32 active = 0;
const char *phase2_auth = NULL;
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ());
if (s_8021x) {
if (nm_setting_802_1x_get_phase2_auth (s_8021x))
......
......@@ -228,7 +228,7 @@ inner_auth_combo_init (EAPMethodTTLS *method,
guint32 active = 0;
const char *phase2_auth = NULL;
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ());
if (s_8021x) {
if (nm_setting_802_1x_get_phase2_auth (s_8021x))
......
......@@ -37,19 +37,7 @@
#include "eap-method.h"
#include "nm-utils.h"
GType
eap_method_get_g_type (void)
{
static GType type_id = 0;
if (!type_id) {
type_id = g_boxed_type_register_static ("EAPMethod",
(GBoxedCopyFunc) eap_method_ref,
(GBoxedFreeFunc) eap_method_unref);
}
return type_id;
}
G_DEFINE_BOXED_TYPE (EAPMethod, eap_method, eap_method_ref, eap_method_unref)
GtkWidget *
eap_method_get_widget (EAPMethod *method)
......
......@@ -73,7 +73,7 @@ EAPMethod *eap_method_ref (EAPMethod *method);
void eap_method_unref (EAPMethod *method);
GType eap_method_get_g_type (void);
GType eap_method_get_type (void);
/* Below for internal use only */
......
......@@ -37,19 +37,7 @@
#include "wireless-security.h"
#include "eap-method.h"
GType
wireless_security_get_g_type (void)
{
static GType type_id = 0;
if (!type_id) {
type_id = g_boxed_type_register_static ("WirelessSecurity",
(GBoxedCopyFunc) wireless_security_ref,
(GBoxedFreeFunc) wireless_security_unref);
}
return type_id;
}
G_DEFINE_BOXED_TYPE (WirelessSecurity, wireless_security, wireless_security_ref, wireless_security_unref)
GtkWidget *
wireless_security_get_widget (WirelessSecurity *sec)
......@@ -414,7 +402,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
/* initialize WirelessSecurity userpass from connection (clear if no connection) */
wireless_security_set_userpass_802_1x (sec, connection);
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ());
if (wired) {
em_md5 = eap_method_simple_new (sec,
......
......@@ -93,7 +93,7 @@ WirelessSecurity *wireless_security_ref (WirelessSecurity *sec);
void wireless_security_unref (WirelessSecurity *sec);
GType wireless_security_get_g_type (void);
GType wireless_security_get_type (void);
/* Below for internal use only */
......
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