[seahorse] Avoid ownership mismatches of container elements to avoid leaking memory
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Avoid ownership mismatches of container elements to avoid leaking memory
- Date: Sun, 8 Apr 2018 08:09:11 +0000 (UTC)
commit fb6fb6f69b4339eb53bfe3a60e9d192a80bec58e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Apr 5 10:57:08 2018 +0200
Avoid ownership mismatches of container elements to avoid leaking memory
common/collection.vala | 5 +----
common/key-manager-store.vala | 2 +-
common/registry.vala | 2 +-
pkcs11/pkcs11-token.vala | 2 +-
ssh/backend.vala | 2 +-
5 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/common/collection.vala b/common/collection.vala
index bdab17f..f10fe1e 100644
--- a/common/collection.vala
+++ b/common/collection.vala
@@ -89,10 +89,7 @@ public class Seahorse.Collection : Gcr.Collection, GLib.Object {
}
public List<weak GLib.Object> get_objects() {
- List<GLib.Object> result = new List<GLib.Object>();
- foreach (GLib.Object obj in this.objects)
- result.append(obj);
- return result;
+ return this.objects.get_values();
}
public bool contains(GLib.Object object) {
diff --git a/common/key-manager-store.vala b/common/key-manager-store.vala
index 0fe17c3..4025f4d 100644
--- a/common/key-manager-store.vala
+++ b/common/key-manager-store.vala
@@ -441,7 +441,7 @@ public class Seahorse.KeyManagerStore : Gcr.CollectionModel {
return ((Gcr.CollectionModel) view.model).object_for_iter(iter);
}
- public List<GLib.Object> get_all_objects() {
+ public List<weak GLib.Object> get_all_objects() {
return get_collection().get_objects();
}
diff --git a/common/registry.vala b/common/registry.vala
index 0f807c8..86cf578 100644
--- a/common/registry.vala
+++ b/common/registry.vala
@@ -87,7 +87,7 @@ public class Registry : GLib.Object {
}
construct {
- _objects = new GLib.HashTable<weak string, GLib.HashTable<GLib.Object,
GLib.Object>>(GLib.str_hash, GLib.str_equal);
+ _objects = new GLib.HashTable<string, GLib.HashTable<GLib.Object,
GLib.Object>>(GLib.str_hash, GLib.str_equal);
}
}
diff --git a/pkcs11/pkcs11-token.vala b/pkcs11/pkcs11-token.vala
index 042381e..ca14d59 100644
--- a/pkcs11/pkcs11-token.vala
+++ b/pkcs11/pkcs11-token.vala
@@ -123,7 +123,7 @@ public class Token : GLib.Object, Gcr.Collection, Place, Lockable {
private Gck.Session? _session;
private GLib.HashTable<ulong?, GLib.Object> _object_for_handle;
private GLib.HashTable<Gck.Attribute, GLib.GenericArray<GLib.Object>> _objects_for_id;
- private GLib.HashTable<GLib.Object, Gck.Attribute> _id_for_object;
+ private GLib.HashTable<GLib.Object, unowned Gck.Attribute> _id_for_object;
private GLib.HashTable<GLib.Object, GLib.Object> _objects_visible;
public Token(Gck.Slot slot) {
diff --git a/ssh/backend.vala b/ssh/backend.vala
index 0bbaeca..4865070 100644
--- a/ssh/backend.vala
+++ b/ssh/backend.vala
@@ -53,7 +53,7 @@ public class Seahorse.Ssh.Backend : GLib.Object, Gcr.Collection, Seahorse.Backen
}
public List<weak GLib.Object> get_objects() {
- List<GLib.Object> list = new List<GLib.Object>();
+ List<weak GLib.Object> list = new List<weak GLib.Object>();
list.append(this.dot_ssh);
return list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]