diff --git a/ChangeLog b/ChangeLog index 261083be5..28c5dc2e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-08-22 Ben Maurer + * gtk/TreeNode.cs: Add Interlocked.Increment rather than ++. This + makes it safe to create tree nodes in a worker thread as long as + you reparent them into the tree with another thread. Thanks to mk + for allowing a bit of threadedness in :-). + * gtk/NodeView.cs: Fix leak here. r=mkestner 2005-08-22 Mike Kestner diff --git a/gtk/TreeNode.cs b/gtk/TreeNode.cs index f3a28bde0..28fc0b2f7 100644 --- a/gtk/TreeNode.cs +++ b/gtk/TreeNode.cs @@ -23,9 +23,11 @@ namespace Gtk { using System; using System.Collections; + using System.Threading; public abstract class TreeNode : ITreeNode { + // Only use interlocked operations static int next_idx = 0; int id; @@ -34,7 +36,7 @@ namespace Gtk { public TreeNode () { - id = next_idx++; + id = Interlocked.Increment (ref next_idx); } public int ID {