Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,22 @@ TreeItem _getItem (long iter) {
parentIter = OS.g_malloc (GTK.GtkTreeIter_sizeof ());
GTK.gtk_tree_model_get_iter (modelHandle, parentIter, path);
}
items [id] = new TreeItem (this, parentIter, SWT.NONE, indices [indices.length -1], false);
items [id] = new TreeItem (this, parentIter, SWT.NONE, indices [indices.length -1], iter);
GTK.gtk_tree_path_free (path);
if (parentIter != 0) OS.g_free (parentIter);
return items [id];
}

TreeItem _getItem (long parentIter, int index) {
long iter = OS.g_malloc (GTK.GtkTreeIter_sizeof ());
GTK.gtk_tree_model_iter_nth_child(modelHandle, iter, parentIter, index);
int id = getId (iter, true);
OS.g_free (iter);
if (items [id] != null) return items [id];
return items [id] = new TreeItem (this, parentIter, SWT.NONE, index, false);
try {
GTK.gtk_tree_model_iter_nth_child (modelHandle, iter, parentIter, index);
int id = getId (iter, true);
if (items [id] != null) return items [id];
return items [id] = new TreeItem (this, parentIter, SWT.NONE, index, iter);
} finally {
OS.g_free (iter);
}
}

void reallocateIds(int newSize) {
Expand Down Expand Up @@ -3532,7 +3535,7 @@ void setItemCount (long parentIter, int count) {
OS.g_free (iters);
} else {
for (int i=itemCount; i<count; i++) {
new TreeItem (this, parentIter, SWT.NONE, itemCount, true);
new TreeItem (this, parentIter, SWT.NONE, itemCount, 0);
}
}
if (!isVirtual) setRedraw (true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class TreeItem extends Item {
* @see Widget#getStyle
*/
public TreeItem (Tree parent, int style) {
this (checkNull (parent), 0, style, -1, true);
this (checkNull (parent), 0, style, -1, 0);
}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ public TreeItem (Tree parent, int style) {
* @see Tree#setRedraw
*/
public TreeItem (Tree parent, int style, int index) {
this (checkNull (parent), 0, style, checkIndex (index), true);
this (checkNull (parent), 0, style, checkIndex (index), 0);
}

/**
Expand All @@ -129,7 +129,7 @@ public TreeItem (Tree parent, int style, int index) {
* @see Widget#getStyle
*/
public TreeItem (TreeItem parentItem, int style) {
this (checkNull (parentItem).parent, parentItem.handle, style, -1, true);
this (checkNull (parentItem).parent, parentItem.handle, style, -1, 0);
}

/**
Expand Down Expand Up @@ -158,17 +158,19 @@ public TreeItem (TreeItem parentItem, int style) {
* @see Tree#setRedraw
*/
public TreeItem (TreeItem parentItem, int style, int index) {
this (checkNull (parentItem).parent, parentItem.handle, style, checkIndex (index), true);
this (checkNull (parentItem).parent, parentItem.handle, style, checkIndex (index), 0);
}

TreeItem (Tree parent, long parentIter, int style, int index, boolean create) {
TreeItem (Tree parent, long parentIter, int style, int index, long iter) {
super (parent, style);
this.parent = parent;
if (create) {
if (iter == 0) {
parent.createItem (this, parentIter, index);
} else {
assert handle == 0;
handle = OS.g_malloc (GTK.GtkTreeIter_sizeof ());
GTK.gtk_tree_model_iter_nth_child (parent.modelHandle, handle, parentIter, index);
if (handle == 0) error(SWT.ERROR_NO_HANDLES);
C.memmove(handle, iter, GTK.GtkTreeIter_sizeof ());
}
}

Expand Down
Loading