[vala/staging] Require and target GLib >= 2.40



commit 90cf68c81c63f1332d8c12a5787f364464c184f7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon May 1 11:15:56 2017 +0200

    Require and target GLib >= 2.40
    
    The next stable release of vala will happen 3.5 years after the
    release of GLib 2.40.0.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782005

 codegen/valaccodemethodmodule.vala |   85 +++++++-----------
 codegen/valagasyncmodule.vala      |  176 ++++++++++++------------------------
 codegen/valagdbusclientmodule.vala |   54 ++++--------
 codegen/valagtkmodule.vala         |    7 --
 compiler/valacompiler.vala         |    2 +-
 configure.ac                       |    2 +-
 vapi/glib-2.0.vapi                 |    4 -
 7 files changed, 108 insertions(+), 222 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 4d0d5fb..744bf7d 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -127,59 +127,40 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                var data_var = new CCodeIdentifier ("_data_");
                var async_result_expr = new CCodeMemberAccess.pointer (data_var, "_async_result");
 
-               if (context.require_glib_version (2, 36)) {
-                       var finish_call = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_return_pointer"));
-                       finish_call.add_argument (async_result_expr);
-                       finish_call.add_argument (data_var);
-                       finish_call.add_argument (new CCodeConstant ("NULL"));
-                       ccode.add_expression (finish_call);
-
-                       // Preserve the "complete now" behavior if state != 0, do so by
-                       //  iterating the GTask's main context till the task is complete.
-                       var state = new CCodeMemberAccess.pointer (data_var, "_state_");
-                       var zero = new CCodeConstant ("0");
-                       var state_is_not_zero = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
state, zero);
-                       ccode.open_if (state_is_not_zero);
-
-                       CCodeBinaryExpression task_is_complete;
-
-                       if (context.require_glib_version (2, 44)) {
-                               var task_complete = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_get_completed"));
-                               task_complete.add_argument (async_result_expr);
-                               task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
task_complete, new CCodeConstant ("TRUE"));
-                       } else {
-                               var task_complete = new CCodeMemberAccess.pointer (data_var, 
"_task_complete_");
-                               task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
task_complete, new CCodeConstant ("TRUE"));
-                       }
-
-                       ccode.open_while (task_is_complete);
-                       var task_context = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_context"));
-                       task_context.add_argument (async_result_expr);
-                       var iterate_context = new CCodeFunctionCall (new CCodeIdentifier 
("g_main_context_iteration"));
-                       iterate_context.add_argument (task_context);
-                       iterate_context.add_argument (new CCodeConstant ("TRUE"));
-                       ccode.add_expression (iterate_context);
-                       ccode.close();
-
-                       ccode.close ();
+               var finish_call = new CCodeFunctionCall (new CCodeIdentifier ("g_task_return_pointer"));
+               finish_call.add_argument (async_result_expr);
+               finish_call.add_argument (data_var);
+               finish_call.add_argument (new CCodeConstant ("NULL"));
+               ccode.add_expression (finish_call);
+
+               // Preserve the "complete now" behavior if state != 0, do so by
+               //  iterating the GTask's main context till the task is complete.
+               var state = new CCodeMemberAccess.pointer (data_var, "_state_");
+               var zero = new CCodeConstant ("0");
+               var state_is_not_zero = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, state, 
zero);
+               ccode.open_if (state_is_not_zero);
+
+               CCodeBinaryExpression task_is_complete;
+
+               if (context.require_glib_version (2, 44)) {
+                       var task_complete = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_get_completed"));
+                       task_complete.add_argument (async_result_expr);
+                       task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
task_complete, new CCodeConstant ("TRUE"));
                } else {
-                       var state = new CCodeMemberAccess.pointer (data_var, "_state_");
-                       var zero = new CCodeConstant ("0");
-                       var state_is_zero = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, state, 
zero);
-                       ccode.open_if (state_is_zero);
-
-                       var idle_call = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_complete_in_idle"));
-                       idle_call.add_argument (async_result_expr);
-                       ccode.add_expression (idle_call);
+                       var task_complete = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
+                       task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
task_complete, new CCodeConstant ("TRUE"));
+               }
 
-                       ccode.add_else ();
+               ccode.open_while (task_is_complete);
+               var task_context = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_context"));
+               task_context.add_argument (async_result_expr);
+               var iterate_context = new CCodeFunctionCall (new CCodeIdentifier 
("g_main_context_iteration"));
+               iterate_context.add_argument (task_context);
+               iterate_context.add_argument (new CCodeConstant ("TRUE"));
+               ccode.add_expression (iterate_context);
+               ccode.close ();
 
-                       var direct_call = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_complete"));
-                       direct_call.add_argument (async_result_expr);
-                       ccode.add_expression (direct_call);
-
-                       ccode.close ();
-               }
+               ccode.close ();
 
                var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
                unref.add_argument (async_result_expr);
@@ -883,10 +864,6 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                ccode.add_expression (mem_profiler_init_call);
                        }
 
-                       var cond = new CCodeIfSection ("!GLIB_CHECK_VERSION (2,35,0)");
-                       ccode.add_statement (cond);
-                       cond.append (new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier 
("g_type_init"))));
-
                        var main_call = new CCodeFunctionCall (new CCodeIdentifier (function.name));
                        if (m.get_parameters ().size == 1) {
                                main_call.add_argument (new CCodeIdentifier ("argv"));
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 74bbf57..002c488 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -31,13 +31,9 @@ public class Vala.GAsyncModule : GtkModule {
                data.add_field ("GObject*", "_source_object_");
                data.add_field ("GAsyncResult*", "_res_");
 
-               if (context.require_glib_version (2, 36)) {
-                       data.add_field ("GTask*", "_async_result");
-                       if (!context.require_glib_version (2, 44)) {
-                               data.add_field ("gboolean", "_task_complete_");
-                       }
-               } else {
-                       data.add_field ("GSimpleAsyncResult*", "_async_result");
+               data.add_field ("GTask*", "_async_result");
+               if (!context.require_glib_version (2, 44)) {
+                       data.add_field ("gboolean", "_task_complete_");
                }
 
                if (m is CreationMethod) {
@@ -215,13 +211,7 @@ public class Vala.GAsyncModule : GtkModule {
                ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_data_"));
                ccode.add_assignment (data_var, dataalloc);
 
-               CCodeFunctionCall? create_result = null;
-
-               if (context.require_glib_version (2, 36)) {
-                       create_result = new CCodeFunctionCall (new CCodeIdentifier ("g_task_new"));
-               } else {
-                       create_result = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_new"));
-               }
+               var create_result = new CCodeFunctionCall (new CCodeIdentifier ("g_task_new"));
 
                var t = m.parent_symbol as TypeSymbol;
                if (!(m is CreationMethod) && m.binding == MemberBinding.INSTANCE &&
@@ -234,50 +224,38 @@ public class Vala.GAsyncModule : GtkModule {
                        create_result.add_argument (new CCodeConstant ("NULL"));
                }
 
-               if (context.require_glib_version (2, 36)) {
-                       Parameter cancellable_param = null;
+               Parameter cancellable_param = null;
 
-                       foreach (Parameter param in m.get_parameters ()) {
-                               if (param.variable_type is ObjectType && 
param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
-                                       cancellable_param = param;
-                                       break;
-                               }
+               foreach (Parameter param in m.get_parameters ()) {
+                       if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name 
() == "GLib.Cancellable") {
+                               cancellable_param = param;
+                               break;
                        }
+               }
 
-                       if (cancellable_param == null) {
-                               create_result.add_argument (new CCodeConstant ("NULL"));
-                       } else {
-                               create_result.add_argument (new CCodeIdentifier (get_variable_cname 
(cancellable_param.name)));
-                       }
+               if (cancellable_param == null) {
+                       create_result.add_argument (new CCodeConstant ("NULL"));
+               } else {
+                       create_result.add_argument (new CCodeIdentifier (get_variable_cname 
(cancellable_param.name)));
                }
 
                create_result.add_argument (new CCodeIdentifier ("_callback_"));
                create_result.add_argument (new CCodeIdentifier ("_user_data_"));
 
-               if (!context.require_glib_version (2, 36)) {
-                       create_result.add_argument (new CCodeIdentifier (get_ccode_real_name (m)));
-               }
-
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_async_result"), 
create_result);
 
-               CCodeFunctionCall attach_data_call;
-
-               if (!context.require_glib_version (2, 36)) {
-                       attach_data_call = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_set_op_res_gpointer"));
-               } else {
-                       if (!context.require_glib_version (2, 44)) {
-                               var task_completed_var = new CCodeMemberAccess.pointer (data_var, 
"_task_complete_");
-                               var callback = new CCodeIdentifier ("_callback_");
-                               var callback_is_null = new CCodeBinaryExpression 
(CCodeBinaryOperator.EQUALITY, callback, new CCodeConstant ("NULL"));
-
-                               ccode.open_if (callback_is_null);
-                               ccode.add_assignment (task_completed_var, new CCodeConstant ("TRUE"));
-                               ccode.close ();
-                       }
+               if (!context.require_glib_version (2, 44)) {
+                       var task_completed_var = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
+                       var callback = new CCodeIdentifier ("_callback_");
+                       var callback_is_null = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, 
callback, new CCodeConstant ("NULL"));
 
-                       attach_data_call = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_set_task_data"));
+                       ccode.open_if (callback_is_null);
+                       ccode.add_assignment (task_completed_var, new CCodeConstant ("TRUE"));
+                       ccode.close ();
                }
 
+               var attach_data_call = new CCodeFunctionCall (new CCodeIdentifier ("g_task_set_task_data"));
+
                attach_data_call.add_argument (new CCodeMemberAccess.pointer (data_var, "_async_result"));
                attach_data_call.add_argument (data_var);
                attach_data_call.add_argument (new CCodeIdentifier (get_ccode_real_name (m) + "_data_free"));
@@ -574,61 +552,41 @@ public class Vala.GAsyncModule : GtkModule {
 
                ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_data_"));
 
-               if (context.require_glib_version (2, 36)) {
-                       var async_result_cast = new CCodeFunctionCall (new CCodeIdentifier ("G_TASK"));
-                       async_result_cast.add_argument (new CCodeIdentifier ("_res_"));
+               var async_result_cast = new CCodeFunctionCall (new CCodeIdentifier ("G_TASK"));
+               async_result_cast.add_argument (new CCodeIdentifier ("_res_"));
 
-                       var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_task_propagate_pointer"));
-                       ccall.add_argument (async_result_cast);
+               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_task_propagate_pointer"));
+               ccall.add_argument (async_result_cast);
 
-                       if (m.get_error_types ().size > 0) {
-                               ccall.add_argument (new CCodeIdentifier ("error"));
-                       } else {
-                               ccall.add_argument (new CCodeConstant ("NULL"));
-                       }
+               if (m.get_error_types ().size > 0) {
+                       ccall.add_argument (new CCodeIdentifier ("error"));
+               } else {
+                       ccall.add_argument (new CCodeConstant ("NULL"));
+               }
 
-                       ccode.add_assignment (data_var, ccall);
+               ccode.add_assignment (data_var, ccall);
 
-                       bool has_cancellable = false;
+               bool has_cancellable = false;
 
-                       foreach (Parameter param in m.get_parameters ()) {
-                               if (param.variable_type is ObjectType && 
param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
-                                       has_cancellable = true;
-                                       break;
-                               }
+               foreach (Parameter param in m.get_parameters ()) {
+                       if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name 
() == "GLib.Cancellable") {
+                               has_cancellable = true;
+                               break;
                        }
+               }
 
-                       // If a task is cancelled, g_task_propagate_pointer returns NULL
-                       if (m.get_error_types ().size > 0 || has_cancellable) {
-                               var is_null = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new 
CCodeConstant ("NULL"), data_var);
-
-                               ccode.open_if (is_null);
-                               return_default_value (return_type);
-                               ccode.close ();
-                       }
+               // If a task is cancelled, g_task_propagate_pointer returns NULL
+               if (m.get_error_types ().size > 0 || has_cancellable) {
+                       var is_null = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new 
CCodeConstant ("NULL"), data_var);
 
-                       if (!context.require_glib_version (2, 44)) {
-                               var task_completed_var = new CCodeMemberAccess.pointer (data_var, 
"_task_complete_");
-                               ccode.add_assignment (task_completed_var, new CCodeConstant ("TRUE"));
-                       }
-               } else {
-                       var simple_async_result_cast = new CCodeFunctionCall (new CCodeIdentifier 
("G_SIMPLE_ASYNC_RESULT"));
-                       simple_async_result_cast.add_argument (new CCodeIdentifier ("_res_"));
-
-                       if (m.get_error_types ().size > 0) {
-                               // propagate error from async method
-                               var propagate_error = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_propagate_error"));
-                               propagate_error.add_argument (simple_async_result_cast);
-                               propagate_error.add_argument (new CCodeIdentifier ("error"));
-
-                               ccode.open_if (propagate_error);
-                               return_default_value (return_type);
-                               ccode.close ();
-                       }
+                       ccode.open_if (is_null);
+                       return_default_value (return_type);
+                       ccode.close ();
+               }
 
-                       var ccall = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_get_op_res_gpointer"));
-                       ccall.add_argument (simple_async_result_cast);
-                       ccode.add_assignment (data_var, ccall);
+               if (!context.require_glib_version (2, 44)) {
+                       var task_completed_var = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
+                       ccode.add_assignment (task_completed_var, new CCodeConstant ("TRUE"));
                }
 
                emit_context.push_symbol (m);
@@ -703,7 +661,7 @@ public class Vala.GAsyncModule : GtkModule {
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_source_object_"), new 
CCodeIdentifier ("source_object"));
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_res_"), new CCodeIdentifier 
("_res_"));
 
-               if (context.require_glib_version (2, 36) && !context.require_glib_version (2, 44)) {
+               if (!context.require_glib_version (2, 44)) {
                        ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_task_complete_"), 
new CCodeConstant ("TRUE"));
                }
 
@@ -806,27 +764,19 @@ public class Vala.GAsyncModule : GtkModule {
                var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), 
"_async_result");
                CCodeFunctionCall set_error = null;
 
-               if (context.require_glib_version (2, 36)) {
-                       set_error = new CCodeFunctionCall (new CCodeIdentifier ("g_task_return_error"));
-               } else {
-                       set_error = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_take_error"));
-               }
+               set_error = new CCodeFunctionCall (new CCodeIdentifier ("g_task_return_error"));
                set_error.add_argument (async_result_expr);
                set_error.add_argument (error_expr);
                ccode.add_expression (set_error);
 
                append_local_free (current_symbol, false);
 
-               if (context.require_glib_version (2, 36)) {
-                       // We already returned the error above, we must not return anything else here.
-                       var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
-                       unref.add_argument (async_result_expr);
-                       ccode.add_expression (unref);
+               // We already returned the error above, we must not return anything else here.
+               var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+               unref.add_argument (async_result_expr);
+               ccode.add_expression (unref);
 
-                       ccode.add_return (new CCodeConstant ("FALSE"));
-               } else {
-                       complete_async ();
-               }
+               ccode.add_return (new CCodeConstant ("FALSE"));
        }
 
        public override void visit_return_statement (ReturnStatement stmt) {
@@ -882,24 +832,12 @@ public class Vala.GAsyncModule : GtkModule {
                CCodeFunctionCall ccall = null;
 
                // store reference to async result of inner async function in out async result
-               if (context.require_glib_version (2, 36)) {
-                       ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_task_return_pointer"));
-               } else {
-                       ccall = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_set_op_res_gpointer"));
-               }
-
+               ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_task_return_pointer"));
                ccall.add_argument (new CCodeIdentifier ("user_data"));
                ccall.add_argument (res_ref);
                ccall.add_argument (new CCodeIdentifier ("g_object_unref"));
                ccode.add_expression (ccall);
 
-               if (!context.require_glib_version (2, 36)) {
-                       // call user-provided callback
-                       ccall = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_complete"));
-                       ccall.add_argument (new CCodeIdentifier ("user_data"));
-                       ccode.add_expression (ccall);
-               }
-
                // free async result
                ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
                ccall.add_argument (new CCodeIdentifier ("user_data"));
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index d986b24..dd8b405 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -706,21 +706,12 @@ public class Vala.GDBusClientModule : GDBusModule {
                                CCodeFunctionCall res_wrapper = null;
 
                                // use wrapper as source_object wouldn't be correct otherwise
-                               if (context.require_glib_version (2, 36)) {
-                                       ccall.add_argument (new CCodeIdentifier 
(generate_async_callback_wrapper ()));
-                                       res_wrapper = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_new"));
-                                       res_wrapper.add_argument (new CCodeCastExpression (new 
CCodeIdentifier ("self"), "GObject *"));
-                                       res_wrapper.add_argument (new CCodeConstant ("NULL"));
-                                       res_wrapper.add_argument (new CCodeIdentifier ("_callback_"));
-                                       res_wrapper.add_argument (new CCodeIdentifier ("_user_data_"));
-                               } else {
-                                       ccall.add_argument (new CCodeIdentifier 
(generate_async_callback_wrapper ()));
-                                       res_wrapper = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_new"));
-                                       res_wrapper.add_argument (new CCodeCastExpression (new 
CCodeIdentifier ("self"), "GObject *"));
-                                       res_wrapper.add_argument (new CCodeIdentifier ("_callback_"));
-                                       res_wrapper.add_argument (new CCodeIdentifier ("_user_data_"));
-                                       res_wrapper.add_argument (new CCodeConstant ("NULL"));
-                               }
+                               ccall.add_argument (new CCodeIdentifier (generate_async_callback_wrapper ()));
+                               res_wrapper = new CCodeFunctionCall (new CCodeIdentifier ("g_task_new"));
+                               res_wrapper.add_argument (new CCodeCastExpression (new CCodeIdentifier 
("self"), "GObject *"));
+                               res_wrapper.add_argument (new CCodeConstant ("NULL"));
+                               res_wrapper.add_argument (new CCodeIdentifier ("_callback_"));
+                               res_wrapper.add_argument (new CCodeIdentifier ("_user_data_"));
                                ccall.add_argument (res_wrapper);
 
                                ccode.add_expression (ccall);
@@ -736,30 +727,21 @@ public class Vala.GDBusClientModule : GDBusModule {
                        ccall.add_argument (connection);
 
                        // unwrap async result
-                       if (context.require_glib_version (2, 36)) {
-                               ccode.add_declaration ("GAsyncResult", new CCodeVariableDeclarator 
("*_inner_res"));
+                       ccode.add_declaration ("GAsyncResult", new CCodeVariableDeclarator ("*_inner_res"));
 
-                               var inner_res = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_propagate_pointer"));
-                               inner_res.add_argument (new CCodeCastExpression (new CCodeIdentifier 
("_res_"), "GTask *"));
-                               inner_res.add_argument (new CCodeConstant ("NULL"));
-                               ccode.add_assignment (new CCodeIdentifier ("_inner_res"), inner_res);
+                       var inner_res = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_propagate_pointer"));
+                       inner_res.add_argument (new CCodeCastExpression (new CCodeIdentifier ("_res_"), 
"GTask *"));
+                       inner_res.add_argument (new CCodeConstant ("NULL"));
+                       ccode.add_assignment (new CCodeIdentifier ("_inner_res"), inner_res);
 
-                               ccall.add_argument (new CCodeIdentifier ("_inner_res"));
-                               ccall.add_argument (error_argument);
-                               ccode.add_assignment (new CCodeIdentifier ("_reply_message"), ccall);
-
-                               // _inner_res is guaranteed to be non-NULL, so just unref it
-                               var unref_inner_res = new CCodeFunctionCall (new CCodeIdentifier 
("g_object_unref"));
-                               unref_inner_res.add_argument (new CCodeIdentifier ("_inner_res"));
-                               ccode.add_expression (unref_inner_res);
-                       } else {
-                               var inner_res = new CCodeFunctionCall (new CCodeIdentifier 
("g_simple_async_result_get_op_res_gpointer"));
-                               inner_res.add_argument (new CCodeCastExpression (new CCodeIdentifier 
("_res_"), "GSimpleAsyncResult *"));
-                               ccall.add_argument (inner_res);
+                       ccall.add_argument (new CCodeIdentifier ("_inner_res"));
+                       ccall.add_argument (error_argument);
+                       ccode.add_assignment (new CCodeIdentifier ("_reply_message"), ccall);
 
-                               ccall.add_argument (error_argument);
-                               ccode.add_assignment (new CCodeIdentifier ("_reply_message"), ccall);
-                       }
+                       // _inner_res is guaranteed to be non-NULL, so just unref it
+                       var unref_inner_res = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+                       unref_inner_res.add_argument (new CCodeIdentifier ("_inner_res"));
+                       ccode.add_expression (unref_inner_res);
                }
 
                if (call_type == CallType.SYNC || call_type == CallType.FINISH) {
diff --git a/codegen/valagtkmodule.vala b/codegen/valagtkmodule.vala
index 1558469..85b648a 100644
--- a/codegen/valagtkmodule.vala
+++ b/codegen/valagtkmodule.vala
@@ -169,13 +169,6 @@ public class Vala.GtkModule : GSignalModule {
                                }
                                return false;
                        }
-                       if (!context.require_glib_version (2, 38)) {
-                               if (!cl.error) {
-                                       Report.error (attr.source_reference, "glib 2.38 is required for using 
Gtk templates (with --target-glib=2.38)");
-                                       cl.error = true;
-                               }
-                               return false;
-                       }
                        return true;
                }
                return false;
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 0b76eec..d2d3997 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -289,7 +289,7 @@ class Vala.Compiler {
                }
 
                int glib_major = 2;
-               int glib_minor = 32;
+               int glib_minor = 40;
                if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
                        Report.error (null, "Invalid format for --target-glib");
                }
diff --git a/configure.ac b/configure.ac
index a448018..b8525ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,7 @@ AC_SUBST(COVERAGE_VALAFLAGS)
 AC_SUBST(COVERAGE_CFLAGS)
 AC_SUBST(COVERAGE_LIBS)
 
-GLIB_REQUIRED=2.32.0
+GLIB_REQUIRED=2.40.0
 
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED)
 
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index d313941..465dd44 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -4007,12 +4007,8 @@ namespace GLib {
        }
 
        [Compact]
-#if GLIB_2_36
        [Version (since = "2.36")]
        [CCode (ref_function = "g_markup_parse_context_ref", unref_function = "g_markup_parse_context_unref", 
type_id = "G_TYPE_MARKUP_PARSE_CONTEXT")]
-#else
-       [CCode (free_function = "g_markup_parse_context_free")]
-#endif
        public class MarkupParseContext {
                public MarkupParseContext (MarkupParser parser, MarkupParseFlags _flags, void* user_data, 
DestroyNotify? user_data_dnotify);
                public bool parse (string text, ssize_t text_len) throws MarkupError;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]