From 0ca6e4080e66f01b5eae4067cba44a2138e96fa8 Mon Sep 17 00:00:00 2001 From: Vasiliy Doylov Date: Sun, 22 Jun 2025 01:58:13 +0300 Subject: [PATCH] Fix refs Signed-off-by: Vasiliy Doylov --- src/logic/config.vala | 6 +++--- src/logic/outbounds/trojan.vala | 5 ++--- src/logic/outbounds/vless.vala | 5 ++--- src/logic/tls.vala | 2 +- src/logic/utils.vala | 6 ++++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/logic/config.vala b/src/logic/config.vala index d0d266e..e9f6046 100644 --- a/src/logic/config.vala +++ b/src/logic/config.vala @@ -24,11 +24,11 @@ class Singularity.SingConfig : Object, Json.Serializable { if (property_name == "outbounds") { var node = Utils.serialize_object_list (outbounds); var arr = node.get_array (); + var new_arr = new Json.Array (); arr.foreach_element ((_, __, node) => { - var _node = node; - Utils.fix_type (ref _node); - Utils.fix_dash (ref _node); + new_arr.add_element (Utils.fix_dash (Utils.fix_type (node))); }); + node.set_array (new_arr); return node; } return default_serialize_property (property_name, value, pspec);; diff --git a/src/logic/outbounds/trojan.vala b/src/logic/outbounds/trojan.vala index 2ad3dff..663251b 100644 --- a/src/logic/outbounds/trojan.vala +++ b/src/logic/outbounds/trojan.vala @@ -42,11 +42,10 @@ class Singularity.Outbound.Trojan : Dial, Json.Serializable { public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) { var node = default_serialize_property (property_name, value, pspec); if (property_name == "transport" && transport != null) { - Utils.fix_type (ref node); - Utils.fix_dash (ref node); + return Utils.fix_dash (Utils.fix_type (node)); } if (property_name == "tls" && tls != null) { - Utils.fix_dash (ref node); + return Utils.fix_dash (node); } return node; } diff --git a/src/logic/outbounds/vless.vala b/src/logic/outbounds/vless.vala index c05a866..fdd4023 100644 --- a/src/logic/outbounds/vless.vala +++ b/src/logic/outbounds/vless.vala @@ -43,11 +43,10 @@ class Singularity.Outbound.Vless : Dial, Json.Serializable { public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) { var node = default_serialize_property (property_name, value, pspec); if (property_name == "transport" && transport != null) { - Utils.fix_type (ref node); - Utils.fix_dash (ref node); + return Utils.fix_dash (Utils.fix_type (node)); } if (property_name == "tls" && tls != null) { - Utils.fix_dash (ref node); + return Utils.fix_dash (node); } return node; } diff --git a/src/logic/tls.vala b/src/logic/tls.vala index 3915a0d..f1b1ea7 100644 --- a/src/logic/tls.vala +++ b/src/logic/tls.vala @@ -37,7 +37,7 @@ class Singularity.TLS : Object, Json.Serializable { public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) { var node = default_serialize_property (property_name, value, pspec); if (property_name == "reality" && reality != null) { - Utils.fix_dash (ref node); + return Utils.fix_dash (node); } return node; } diff --git a/src/logic/utils.vala b/src/logic/utils.vala index a7acc2a..6233a31 100644 --- a/src/logic/utils.vala +++ b/src/logic/utils.vala @@ -26,7 +26,7 @@ namespace Singularity.Utils { * Vala use `meow-meow-meow` as in json serialization, but we need to use * `meow_meow_meow` to make our saves compatible with SingBox configuration. */ - public void fix_dash(ref Json.Node node, bool serialize = true) { + public Json.Node fix_dash(Json.Node node, bool serialize = true) { var type = node.get_value_type(); if (type == typeof (Json.Object)) { var obj = node.get_object(); @@ -36,13 +36,14 @@ namespace Singularity.Utils { obj.remove_member(name); } } + return node; } /* * In vala we can't use `type` as field name, but we need to use it * to make our saves compatible with SingBox configuration. */ - public void fix_type(ref Json.Node node) { + public Json.Node fix_type(Json.Node node) { const string TYPE_NAME_SRC = "type-name"; const string TYPE_NAME_DST = "type"; @@ -58,6 +59,7 @@ namespace Singularity.Utils { } else { warning("Object has no type to fix it"); } + return node; } /*