mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 13:55:30 +00:00
sample: Fix crashes in TreeModelDemo
This commit is contained in:
parent
306f422c38
commit
de6b6029ec
|
@ -105,10 +105,12 @@ namespace GtkSamples {
|
||||||
TreeIter IterFromNode (object node)
|
TreeIter IterFromNode (object node)
|
||||||
{
|
{
|
||||||
GCHandle gch;
|
GCHandle gch;
|
||||||
if (node_hash [node] != null)
|
if (node_hash [node] != null) {
|
||||||
gch = (GCHandle) node_hash [node];
|
gch = (GCHandle) node_hash [node];
|
||||||
else
|
} else {
|
||||||
gch = GCHandle.Alloc (node);
|
gch = GCHandle.Alloc (node);
|
||||||
|
node_hash [node] = gch;
|
||||||
|
}
|
||||||
TreeIter result = TreeIter.Zero;
|
TreeIter result = TreeIter.Zero;
|
||||||
result.UserData = (IntPtr) gch;
|
result.UserData = (IntPtr) gch;
|
||||||
return result;
|
return result;
|
||||||
|
@ -128,7 +130,7 @@ namespace GtkSamples {
|
||||||
object work = node;
|
object work = node;
|
||||||
TreePath path = new TreePath ();
|
TreePath path = new TreePath ();
|
||||||
|
|
||||||
if (work is MemberInfo) {
|
if ((work is MemberInfo) && !(work is Type)) {
|
||||||
Type parent = (work as MemberInfo).ReflectedType;
|
Type parent = (work as MemberInfo).ReflectedType;
|
||||||
path.PrependIndex (Array.IndexOf (parent.GetMembers (), work));
|
path.PrependIndex (Array.IndexOf (parent.GetMembers (), work));
|
||||||
work = parent;
|
work = parent;
|
||||||
|
@ -140,8 +142,9 @@ namespace GtkSamples {
|
||||||
work = assm;
|
work = assm;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (work is Assembly)
|
if (work is Assembly) {
|
||||||
path.PrependIndex (Array.IndexOf (assemblies, node));
|
path.PrependIndex (Array.IndexOf (assemblies, work));
|
||||||
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue