mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 23:55:26 +00:00
glib: add missing lock statements for Objects collection
When accessing the static Objects collection in GLib.Object class, a lock was held in some places but not all of them. Brought up by Alan McGovern. Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
This commit is contained in:
parent
b5e0d297bb
commit
61b67120c2
|
@ -87,9 +87,13 @@ namespace GLib {
|
|||
if (o == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
ToggleRef tr = (ToggleRef) Objects[o];
|
||||
if (tr != null) {
|
||||
return tr.Target;
|
||||
ToggleRef toggle_ref;
|
||||
lock (Objects) {
|
||||
toggle_ref = (ToggleRef) Objects[o];
|
||||
}
|
||||
|
||||
if (toggle_ref != null) {
|
||||
return toggle_ref.Target;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -103,9 +107,11 @@ namespace GLib {
|
|||
Object obj = null;
|
||||
|
||||
ToggleRef toggle_ref;
|
||||
if (Objects.TryGetValue (o, out toggle_ref)) {
|
||||
if (toggle_ref != null)
|
||||
obj = toggle_ref.Target;
|
||||
lock (Objects) {
|
||||
if (Objects.TryGetValue (o, out toggle_ref)) {
|
||||
if (toggle_ref != null)
|
||||
obj = toggle_ref.Target;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj != null && obj.Handle == o) {
|
||||
|
@ -540,17 +546,20 @@ namespace GLib {
|
|||
if (handle == value)
|
||||
return;
|
||||
|
||||
if (handle != IntPtr.Zero) {
|
||||
Objects.Remove (handle);
|
||||
if (tref != null) {
|
||||
tref.Dispose ();
|
||||
tref = null;
|
||||
lock (Objects) {
|
||||
if (handle != IntPtr.Zero) {
|
||||
Objects.Remove (handle);
|
||||
if (tref != null) {
|
||||
tref.Dispose ();
|
||||
tref = null;
|
||||
}
|
||||
}
|
||||
|
||||
handle = value;
|
||||
if (value != IntPtr.Zero) {
|
||||
tref = new ToggleRef (this);
|
||||
Objects [value] = tref;
|
||||
}
|
||||
}
|
||||
handle = value;
|
||||
if (value != IntPtr.Zero) {
|
||||
tref = new ToggleRef (this);
|
||||
Objects [value] = tref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue