New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom TreeModel implementations (that are Trees) broken #130
Comments
This change happened in the 3.0 release. Initializing the iter in your implementation of iterChildren should fix the problem. |
I see in the gtk docs that iter_children has "iter" marked as "out", but I'm not seeing that behavior in the gtk3 override bool iterChildren(TreeIter iter, TreeIter parent)
{
RMObject rmObj;
RMObject parentObj;
assert(iter !is null) //iter passed in is not uninitialized like expected
if ( parent is null )
{
rmObj = cast(RMObject)root.getChildren[0];
}
else
{
parentObj = cast(RMObject)parent.userData;
auto children = parentObj.getChildren;
if(children.length == 0)
return false;
rmObj = cast(RMObject) children[0];
}
/* Set iter to first item in list */
iter.stamp = stamp;
iter.userData = cast(void*)rmObj;
return true;
} when doing it this way override bool iterChildren(out TreeIter iter, TreeIter parent)
{
RMObject rmObj;
RMObject parentObj;
assert(iter !is null) //iter passed in is not uninitialized like expected
if ( parent is null )
{
rmObj = cast(RMObject)root.getChildren[0];
}
else
{
parentObj = cast(RMObject)parent.userData;
auto children = parentObj.getChildren;
if(children.length == 0)
return false;
rmObj = cast(RMObject) children[0];
}
iter = new TreeIter(); //initializing new Iter
iter.stamp = stamp;
iter.userData = cast(void*)rmObj;
return true;
} it breaks later in iterParent because the child passed into iterParent is invalid When initializing the Tree Model, I initialize TreeIter for every node in my tree including children void appendObj(RMObject obj)
{
TreeIter iter;
TreePath path;
//this can be a path with depth(ie child)
path = getPathFromObject(obj);
assert(path !is null);
iter = new TreeIter();
getIter(iter, path);
rowInserted(path, iter);
}
maybe that is where i'm going wrong, but it doesn't make sense to me to allocate a new iterator everytime you iterate through children. |
Does commit 8ce74d8 make any difference with this issue? |
When creating a custom tree model that is a Tree(not a simple list) like in Demos\gtkD\DemoCustomList, the model will crash when trying to expand child nodes.
in TreeModelIF.d "iterChildren" "iterHasChild" etc changed from
public bool iterChildren(TreeIter iter, TreeIter parent);
to
public bool iterChildren(out TreeIter iter, TreeIter parent);
when I revert related changes my custom TreeModel works fine with children.
gtk 3.18, windows
The text was updated successfully, but these errors were encountered: