void-packages/srcpkgs/glib/patches/gobject_init_on_demand.patch
Đoàn Trần Công Danh 7fc9190f0e srcpkgs/g*: convert patches to -Np1
* gcc is kept at -Np0, because of void-cross

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

91 lines
2.1 KiB
Diff

Initialize the gobject system on demand, i.e. before it is
expected to be initialized. Do this only once by checking
a local static variable gobject_initialized.
--- a/gobject/gtype.c 2016-08-17 17:20:47.000000000 +0200
+++ b/gobject/gtype.c 2016-09-01 21:56:31.777406646 +0200
@@ -209,6 +209,9 @@
static gboolean type_node_is_a_L (TypeNode *node,
TypeNode *iface_node);
+#if !defined(__GLIBC__)
+static void gobject_init (void);
+#endif
/* --- enumeration --- */
@@ -2631,7 +2634,10 @@
GTypeFlags flags)
{
TypeNode *node;
-
+
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
g_return_val_if_fail (type_id > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
@@ -2749,6 +2755,9 @@
TypeNode *pnode, *node;
GType type = 0;
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
g_return_val_if_fail (parent_type > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
@@ -2804,6 +2813,9 @@
TypeNode *pnode, *node;
GType type;
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
g_return_val_if_fail (parent_type > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
@@ -3319,6 +3331,9 @@
{
TypeNode *node;
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
node = lookup_type_node_I (type);
@@ -4343,6 +4358,9 @@
void
g_type_init_with_debug_flags (GTypeDebugFlags debug_flags)
{
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
if (debug_flags)
@@ -4361,6 +4379,9 @@
void
g_type_init (void)
{
+#if !defined(__GLIBC__)
+ gobject_init();
+#endif
g_assert_type_system_initialized ();
}
@@ -4372,6 +4393,12 @@
TypeNode *node;
GType type;
+#if !defined(__GLIBC__)
+ static int gobject_initialized = 0;
+ if (gobject_initialized)
+ return;
+ gobject_initialized = 1;
+#endif
/* Ensure GLib is initialized first, see
* https://bugzilla.gnome.org/show_bug.cgi?id=756139
*/