From 7bd8181b81ee36eedfcf1aab726327c51faa6527 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 11 Mar 2018 22:56:14 +0100
Subject: [PATCH] network: Fix crash due to object name clashes in NM and g-c-c

1. open Wi-Fi Settings
2. Menu -> Known Wi-fi Networks
3. Click settings of some Wi-Fi network listed there.
4. Press escape twice to close all the dialogs
5. Menu -> Connect to Hidden network..,

Fix crashes when some object type names (WirelessSecurity and
EAPMethod in this case) are duplicated across the Network
panel and libnma.

Fixes a regression in commit 0470c04

https://bugzilla.gnome.org/show_bug.cgi?id=785099
---
 panels/network/wireless-security/eap-method.c | 14 +++++++++-
 ...m-connection-editor-to-network-panel.patch | 27 ++++++++++++++++++-
 .../wireless-security/wireless-security.c     |  2 +-
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
index cb733e861..824f315a3 100644
--- a/panels/network/wireless-security/eap-method.c
+++ b/panels/network/wireless-security/eap-method.c
@@ -34,7 +34,19 @@
 #include "utils.h"
 #include "helpers.h"
 
-G_DEFINE_BOXED_TYPE (EAPMethod, eap_method, eap_method_ref, eap_method_unref)
+GType
+eap_method_get_type (void)
+{
+       static GType type_id = 0;
+
+       if (!type_id) {
+               type_id = g_boxed_type_register_static ("CcEAPMethod",
+                                                       (GBoxedCopyFunc) eap_method_ref,
+                                                       (GBoxedFreeFunc) eap_method_unref);
+       }
+
+       return type_id;
+}
 
 GtkWidget *
 eap_method_get_widget (EAPMethod *method)
diff --git a/panels/network/wireless-security/nm-connection-editor-to-network-panel.patch b/panels/network/wireless-security/nm-connection-editor-to-network-panel.patch
index 0edabb1f9..ed9135cbb 100644
--- a/panels/network/wireless-security/nm-connection-editor-to-network-panel.patch
+++ b/panels/network/wireless-security/nm-connection-editor-to-network-panel.patch
@@ -1,3 +1,28 @@
+diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
+index cb733e861..824f315a3 100644
+--- a/panels/network/wireless-security/eap-method.c
++++ b/panels/network/wireless-security/eap-method.c
+@@ -34,7 +34,19 @@
+ #include "utils.h"
+ #include "helpers.h"
+ 
+-G_DEFINE_BOXED_TYPE (EAPMethod, eap_method, eap_method_ref, eap_method_unref)
++GType
++eap_method_get_type (void)
++{
++       static GType type_id = 0;
++
++       if (!type_id) {
++               type_id = g_boxed_type_register_static ("CcEAPMethod",
++                                                       (GBoxedCopyFunc) eap_method_ref,
++                                                       (GBoxedFreeFunc) eap_method_unref);
++       }
++
++       return type_id;
++}
+ 
+ GtkWidget *
+ eap_method_get_widget (EAPMethod *method)
 diff --git a/panels/network/wireless-security/wireless-security.c b/panels/network/wireless-security/wireless-security.c
 index 23b8a27..bd233b0 100644
 --- a/panels/network/wireless-security/wireless-security.c
@@ -19,7 +44,7 @@ index 23b8a27..bd233b0 100644
 +	if (!type_id) {
 +		g_resources_register (wireless_security_get_resource ());
 +
-+		type_id = g_boxed_type_register_static ("WirelessSecurity",
++		type_id = g_boxed_type_register_static ("CcWirelessSecurity",
 +							(GBoxedCopyFunc) wireless_security_ref,
 +							(GBoxedFreeFunc) wireless_security_unref);
 +	}
diff --git a/panels/network/wireless-security/wireless-security.c b/panels/network/wireless-security/wireless-security.c
index 8c179a764..bbfb3ab17 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -37,7 +37,7 @@ wireless_security_get_type (void)
 	if (!type_id) {
 		g_resources_register (wireless_security_get_resource ());
 
-		type_id = g_boxed_type_register_static ("WirelessSecurity",
+		type_id = g_boxed_type_register_static ("CcWirelessSecurity",
 							(GBoxedCopyFunc) wireless_security_ref,
 							(GBoxedFreeFunc) wireless_security_unref);
 	}
-- 
2.17.0

