[gnome-control-center/wip/gbsneto/new-network-panel: 29/34] network: Ensure WirelessSecurity type is initialized
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-network-panel: 29/34] network: Ensure WirelessSecurity type is initialized
- Date: Mon, 7 Aug 2017 19:21:45 +0000 (UTC)
commit 877f687ae5e697c3826ca4844d149dd90d80a2cf
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 21 10:34:18 2017 -0300
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
.../network/connection-editor/ce-page-security.c | 2 +-
.../network/wireless-security/wireless-security.c | 2 ++
.../network/wireless-security/wireless-security.h | 2 ++
3 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-security.c
b/panels/network/connection-editor/ce-page-security.c
index 1f0eceb..d06e3ae 100644
--- a/panels/network/connection-editor/ce-page-security.c
+++ b/panels/network/connection-editor/ce-page-security.c
@@ -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,
diff --git a/panels/network/wireless-security/wireless-security.c
b/panels/network/wireless-security/wireless-security.c
index b29d50e..8c179a7 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -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);
diff --git a/panels/network/wireless-security/wireless-security.h
b/panels/network/wireless-security/wireless-security.h
index 4de618e..975e750 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]