changeset 71:9ec8791aaa84

Fixed garbage being returned in the item select event on the tree control... Apparently we don't make a copy of the text in the tree... so the Go garbage collector is freeing the strings... This commit introduces a memory leak (when tree items or the tree is destroyed) but fixes the garbage in the callbacks... will need to consider making copies of the strings in DW itself and freeing them when the tree items are deleted.
author Brian Smith <brian@dbsoft.org>
date Wed, 20 Mar 2013 14:59:24 -0500
parents d57cd6f0c947
children 343b8d968ef4
files src/dw/dw.go
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/dw/dw.go	Wed Mar 20 14:27:46 2013 -0500
+++ b/src/dw/dw.go	Wed Mar 20 14:59:24 2013 -0500
@@ -2910,7 +2910,7 @@
 
 func Tree_insert(handle HANDLE, title string, icon HICN, parent HTREEITEM, itemdata POINTER) HTREEITEM {
    ctitle := C.CString(title);
-   defer C.free(unsafe.Pointer(ctitle));
+   //defer C.free(unsafe.Pointer(ctitle));
    
    return HTREEITEM{C.go_tree_insert(handle.GetHandle(), ctitle, unsafe.Pointer(icon), parent.htreeitem, unsafe.Pointer(itemdata)), handle};
 }
@@ -2921,7 +2921,7 @@
 
 func Tree_insert_after(handle HANDLE, item HTREEITEM, title string, icon HICN, parent HTREEITEM, itemdata POINTER) HTREEITEM {
    ctitle := C.CString(title);
-   defer C.free(unsafe.Pointer(ctitle));
+   //defer C.free(unsafe.Pointer(ctitle));
    
    return HTREEITEM{C.go_tree_insert_after(handle.GetHandle(), item.htreeitem, ctitle, unsafe.Pointer(icon), parent.htreeitem, unsafe.Pointer(itemdata)), handle};
 }
@@ -2948,7 +2948,7 @@
 
 func Tree_item_change(handle HANDLE, item HTREEITEM, title string, icon HICN) {
    ctitle := C.CString(title);
-   defer C.free(unsafe.Pointer(ctitle));
+   //defer C.free(unsafe.Pointer(ctitle));
    
    C.go_tree_item_change(handle.GetHandle(), item.htreeitem, ctitle, unsafe.Pointer(icon));
 }