From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Subject: Don't add g_thread_init() in generated code anymore.

g_thread_init has been deprecated for a long while now, and hasn't been
required in code at least since Lucid. It's now been completed dropped by
upstream so we should avoid adding it in code generated by vala.

This only affects applications written in vala calling Gtk.init(), *if*
they are compiled with the "--thread" flag to valac.

Index: vala-0.14/codegen/valaccodemethodmodule.vala
===================================================================
--- vala-0.14.orig/codegen/valaccodemethodmodule.vala	2012-01-25 20:22:13.664363417 -0500
+++ vala-0.14/codegen/valaccodemethodmodule.vala	2012-01-25 20:33:10.540386905 -0500
@@ -685,13 +685,6 @@
 					ccode.add_expression (mem_profiler_init_call);
 				}
 
-				if (context.thread) {
-					var thread_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_thread_init"));
-					thread_init_call.line = cmain.line;
-					thread_init_call.add_argument (new CCodeConstant ("NULL"));
-					ccode.add_expression (thread_init_call);
-				}
-
 				ccode.add_expression (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init")));
 			}
 
Index: vala-0.14/gobject-introspection/scanner.c
===================================================================
--- vala-0.14.orig/gobject-introspection/scanner.c	2012-01-25 20:22:13.656363419 -0500
+++ vala-0.14/gobject-introspection/scanner.c	2012-01-25 20:33:10.540386905 -0500
@@ -1761,11 +1761,6 @@
 
   g_type_init ();
 
-  /* initialize threading as this may be required by libraries that we'll use
-   * libsoup-2.2 is an example of that.
-   */
-  g_thread_init (NULL);
-
   if (include_idls)
     {
       for (i = 0; i < g_strv_length (include_idls); i++)
Index: vala-0.14/codegen/valaccodemethodmodule.c
===================================================================
--- vala-0.14.orig/codegen/valaccodemethodmodule.c	2012-01-25 20:22:13.676363420 -0500
+++ vala-0.14/codegen/valaccodemethodmodule.c	2012-01-25 20:35:10.716391204 -0500
@@ -4982,10 +4982,6 @@
 			ValaCodeContext* _tmp1156_;
 			gboolean _tmp1157_;
 			gboolean _tmp1158_;
-			ValaCodeContext* _tmp1173_;
-			ValaCodeContext* _tmp1174_;
-			gboolean _tmp1175_;
-			gboolean _tmp1176_;
 			ValaCCodeFunction* _tmp1191_;
 			ValaCCodeFunction* _tmp1192_;
 			ValaCCodeIdentifier* _tmp1193_;
@@ -5034,48 +5030,6 @@
 				vala_ccode_function_add_expression (_tmp1171_, (ValaCCodeExpression*) _tmp1172_);
 				_vala_ccode_node_unref0 (mem_profiler_init_call);
 			}
-			_tmp1173_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
-			_tmp1174_ = _tmp1173_;
-			_tmp1175_ = vala_code_context_get_thread (_tmp1174_);
-			_tmp1176_ = _tmp1175_;
-			if (_tmp1176_) {
-				ValaCCodeIdentifier* _tmp1177_;
-				ValaCCodeIdentifier* _tmp1178_;
-				ValaCCodeFunctionCall* _tmp1179_;
-				ValaCCodeFunctionCall* _tmp1180_;
-				ValaCCodeFunctionCall* thread_init_call;
-				ValaCCodeFunctionCall* _tmp1181_;
-				ValaCCodeFunction* _tmp1182_;
-				ValaCCodeLineDirective* _tmp1183_;
-				ValaCCodeLineDirective* _tmp1184_;
-				ValaCCodeFunctionCall* _tmp1185_;
-				ValaCCodeConstant* _tmp1186_;
-				ValaCCodeConstant* _tmp1187_;
-				ValaCCodeFunction* _tmp1188_;
-				ValaCCodeFunction* _tmp1189_;
-				ValaCCodeFunctionCall* _tmp1190_;
-				_tmp1177_ = vala_ccode_identifier_new ("g_thread_init");
-				_tmp1178_ = _tmp1177_;
-				_tmp1179_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp1178_);
-				_tmp1180_ = _tmp1179_;
-				_vala_ccode_node_unref0 (_tmp1178_);
-				thread_init_call = _tmp1180_;
-				_tmp1181_ = thread_init_call;
-				_tmp1182_ = cmain;
-				_tmp1183_ = vala_ccode_node_get_line ((ValaCCodeNode*) _tmp1182_);
-				_tmp1184_ = _tmp1183_;
-				vala_ccode_node_set_line ((ValaCCodeNode*) _tmp1181_, _tmp1184_);
-				_tmp1185_ = thread_init_call;
-				_tmp1186_ = vala_ccode_constant_new ("NULL");
-				_tmp1187_ = _tmp1186_;
-				vala_ccode_function_call_add_argument (_tmp1185_, (ValaCCodeExpression*) _tmp1187_);
-				_vala_ccode_node_unref0 (_tmp1187_);
-				_tmp1188_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
-				_tmp1189_ = _tmp1188_;
-				_tmp1190_ = thread_init_call;
-				vala_ccode_function_add_expression (_tmp1189_, (ValaCCodeExpression*) _tmp1190_);
-				_vala_ccode_node_unref0 (thread_init_call);
-			}
 			_tmp1191_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
 			_tmp1192_ = _tmp1191_;
 			_tmp1193_ = vala_ccode_identifier_new ("g_type_init");
