network: Ensure WirelessSecurity type is initialized

When calling for the wireless security widgets, the code
simply assumes that the corresponding GType is initialized.
This may not always be true, which leads to a nasty crash
every time e.g. we open the network connection editor dialog.

This commit fixes that by introducing a new standard macro
wrapping wireless_security_get_type(), and ensuring the type
is initializing when calling wireless_security_init(), thus
protecting every code path from this crash.

This commit also makes CePageSecurity use the new macro for
better legibility.

https://bugzilla.gnome.org/show_bug.cgi?id=785581
This commit is contained in:
Georges Basile Stavracas Neto 2017-07-21 10:34:18 -03:00 committed by Rui Matos
parent 965ef93143
commit 21943a42bf
3 changed files with 5 additions and 1 deletions

View file

@ -238,7 +238,7 @@ finish_setup (CEPageSecurity *page)
if (sws)
default_type = get_default_type_for_security (sws);
sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_type (), G_TYPE_BOOLEAN);
sec_model = gtk_list_store_new (3, G_TYPE_STRING, WIRELESS_TYPE_SECURITY, G_TYPE_BOOLEAN);
if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
gtk_list_store_insert_with_values (sec_model, &iter, -1,

View file

@ -172,6 +172,8 @@ wireless_security_init (gsize obj_size,
g_return_val_if_fail (ui_resource != NULL, NULL);
g_return_val_if_fail (ui_widget_name != NULL, NULL);
g_type_ensure (WIRELESS_TYPE_SECURITY);
sec = g_slice_alloc0 (obj_size);
g_assert (sec);

View file

@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#define WIRELESS_TYPE_SECURITY (wireless_security_get_type ())
typedef struct _WirelessSecurity WirelessSecurity;
typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);