mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 06:35:41 +00:00
Object: Use the type as top-level key for properties hash
Types could use same param_spec object so their PropertyInfo objects shouldn't be mixed, otherwise we could get type mismatch errors like the one in: http://mail.gnome.org/archives/banshee-list/2011-November/msg00141.html This should be the final part of: https://bugzilla.novell.com/show_bug.cgi?id=442068
This commit is contained in:
parent
9d319c8033
commit
1215ebc770
|
@ -151,13 +151,14 @@ namespace GLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key: The pointer to the ParamSpec of the property
|
// Key: The Type for the set of properties
|
||||||
// Value: The corresponding PropertyInfo object
|
// Value->SubKey: The pointer to the ParamSpec of the property
|
||||||
static Dictionary<IntPtr, PropertyInfo> properties;
|
// Value->SubValue: The corresponding PropertyInfo object
|
||||||
static Dictionary<IntPtr, PropertyInfo> Properties {
|
static Dictionary<Type, Dictionary<IntPtr, PropertyInfo>> properties;
|
||||||
|
static Dictionary<Type, Dictionary<IntPtr, PropertyInfo>> Properties {
|
||||||
get {
|
get {
|
||||||
if (properties == null)
|
if (properties == null)
|
||||||
properties = new Dictionary<IntPtr, PropertyInfo> ();
|
properties = new Dictionary<Type, Dictionary<IntPtr, PropertyInfo>> ();
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +308,13 @@ namespace GLib {
|
||||||
PropertyAttribute property_attr = attr as PropertyAttribute;
|
PropertyAttribute property_attr = attr as PropertyAttribute;
|
||||||
try {
|
try {
|
||||||
IntPtr param_spec = RegisterProperty (gtype, property_attr.Name, property_attr.Nickname, property_attr.Blurb, idx, (GType) pinfo.PropertyType, pinfo.CanRead, pinfo.CanWrite);
|
IntPtr param_spec = RegisterProperty (gtype, property_attr.Name, property_attr.Nickname, property_attr.Blurb, idx, (GType) pinfo.PropertyType, pinfo.CanRead, pinfo.CanWrite);
|
||||||
Properties.Add (param_spec, pinfo);
|
Type type = (Type)gtype;
|
||||||
|
Dictionary<IntPtr, PropertyInfo> gtype_properties;
|
||||||
|
if (!Properties.TryGetValue (type, out gtype_properties)) {
|
||||||
|
gtype_properties = new Dictionary<IntPtr, PropertyInfo> ();
|
||||||
|
Properties [type] = gtype_properties;
|
||||||
|
}
|
||||||
|
gtype_properties.Add (param_spec, pinfo);
|
||||||
idx++;
|
idx++;
|
||||||
} catch (ArgumentException) {
|
} catch (ArgumentException) {
|
||||||
throw new InvalidOperationException (String.Format ("GLib.PropertyAttribute cannot be applied to property {0} of type {1} because the return type of the property is not supported", pinfo.Name, t.FullName));
|
throw new InvalidOperationException (String.Format ("GLib.PropertyAttribute cannot be applied to property {0} of type {1} because the return type of the property is not supported", pinfo.Name, t.FullName));
|
||||||
|
@ -321,11 +328,18 @@ namespace GLib {
|
||||||
|
|
||||||
static void GetPropertyCallback (IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
|
static void GetPropertyCallback (IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
|
||||||
{
|
{
|
||||||
if (!Properties.ContainsKey (param_spec))
|
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
||||||
|
var type = (Type)obj.LookupGType ();
|
||||||
|
|
||||||
|
Dictionary<IntPtr, PropertyInfo> props;
|
||||||
|
if (!Properties.TryGetValue (type, out props))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
PropertyInfo prop;
|
||||||
value.Val = Properties [param_spec].GetValue (obj, new object [0]);
|
if (!props.TryGetValue (param_spec, out prop))
|
||||||
|
return;
|
||||||
|
|
||||||
|
value.Val = prop.GetValue (obj, new object [0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GetPropertyDelegate get_property_handler;
|
static GetPropertyDelegate get_property_handler;
|
||||||
|
@ -352,11 +366,18 @@ namespace GLib {
|
||||||
o.Raw = handle;
|
o.Raw = handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Properties.ContainsKey (param_spec))
|
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
||||||
|
var type = (Type)obj.LookupGType ();
|
||||||
|
|
||||||
|
Dictionary<IntPtr, PropertyInfo> props;
|
||||||
|
if (!Properties.TryGetValue (type, out props))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
PropertyInfo prop;
|
||||||
Properties [param_spec].SetValue (obj, value.Val, new object [0]);
|
if (!props.TryGetValue (param_spec, out prop))
|
||||||
|
return;
|
||||||
|
|
||||||
|
prop.SetValue (obj, value.Val, new object [0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SetPropertyDelegate set_property_handler;
|
static SetPropertyDelegate set_property_handler;
|
||||||
|
@ -406,7 +427,13 @@ namespace GLib {
|
||||||
continue;
|
continue;
|
||||||
IntPtr param_spec = FindInterfaceProperty (adapter.GType, property_attr.Name);
|
IntPtr param_spec = FindInterfaceProperty (adapter.GType, property_attr.Name);
|
||||||
|
|
||||||
Properties [param_spec] = declared_prop;
|
Type type = (Type)adapter.GType;
|
||||||
|
Dictionary<IntPtr, PropertyInfo> props;
|
||||||
|
if (!Properties.TryGetValue (type, out props)) {
|
||||||
|
props = new Dictionary<IntPtr, PropertyInfo> ();
|
||||||
|
Properties [type] = props;
|
||||||
|
}
|
||||||
|
props [param_spec] = declared_prop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue