summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-09-03 16:01:51 +0200
committerJiří Klimeš <jklimes@redhat.com>2013-09-13 09:52:50 +0200
commit36a316be6cb424552782970c48305990e5af8437 (patch)
tree59ea13ab6437614ab12df62c85740b3ad0545ce7
parentf1d3307fc8c030dc26b280a5c5cd895f87ded2b7 (diff)
downloadnetwork-manager-applet-36a316be6cb424552782970c48305990e5af8437.tar.gz
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
-rw-r--r--src/connection-editor/page-wifi-security.c2
-rw-r--r--src/libnm-gtk/nm-wifi-dialog.c2
-rw-r--r--src/wireless-security/eap-method-fast.c2
-rw-r--r--src/wireless-security/eap-method-peap.c2
-rw-r--r--src/wireless-security/eap-method-ttls.c2
-rw-r--r--src/wireless-security/eap-method.c14
-rw-r--r--src/wireless-security/eap-method.h2
-rw-r--r--src/wireless-security/wireless-security.c16
-rw-r--r--src/wireless-security/wireless-security.h2
9 files changed, 10 insertions, 34 deletions
diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c
index bd4e918d..488898c0 100644
--- a/src/connection-editor/page-wifi-security.c
+++ b/src/connection-editor/page-wifi-security.c
@@ -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);
diff --git a/src/libnm-gtk/nm-wifi-dialog.c b/src/libnm-gtk/nm-wifi-dialog.c
index 7d075498..c2fee7dc 100644
--- a/src/libnm-gtk/nm-wifi-dialog.c
+++ b/src/libnm-gtk/nm-wifi-dialog.c
@@ -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);
diff --git a/src/wireless-security/eap-method-fast.c b/src/wireless-security/eap-method-fast.c
index e34c3f57..853367f8 100644
--- a/src/wireless-security/eap-method-fast.c
+++ b/src/wireless-security/eap-method-fast.c
@@ -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))
diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c
index 51a32a74..f8ef35bb 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -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))
diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c
index bf50e74b..e8c9e4d2 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -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))
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index 28e2e051..3f17715c 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -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)
diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h
index b45e9d08..21865843 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -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 */
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index bd650fd0..b7d22ab7 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -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,
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index 149a21dc..4a1a4fe8 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -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 */