From 1fd265135d17d682b3e0f884502ffa2037a379ae Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 Feb 2015 22:17:58 -0500 Subject: [PATCH] Fixed the other build errors. Awesome, Go's linker won't recognize the COM IIDs in uuid.dll; guess we're bumping the minimum required version of Go, maybe?... --- image_windows.c | 2 +- table_windows.go | 12 ++++++------ winapi_windows.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/image_windows.c b/image_windows.c index 7e57bff..bcea3c4 100644 --- a/image_windows.c +++ b/image_windows.c @@ -28,7 +28,7 @@ HBITMAP toBitmap(void *i, intptr_t dx, intptr_t dy) return bitmap; } -void freeBitmap(void *bitmap) +void freeBitmap(uintptr_t bitmap) { if (DeleteObject((HBITMAP) bitmap) == 0) xpanic("error deleting bitmap in freeBitmap()", GetLastError()); diff --git a/table_windows.go b/table_windows.go index efc3e8d..e2aecf1 100644 --- a/table_windows.go +++ b/table_windows.go @@ -7,6 +7,7 @@ import ( "reflect" "unsafe" "sync" + "image" ) // #include "winapi_windows.h" @@ -19,7 +20,7 @@ type table struct { colcount C.int selected *event chainresize func(x int, y int, width int, height int, d *sizing) - freeTexts map[C.uintptr_t]bool + free map[C.uintptr_t]bool freeLock sync.Mutex } @@ -39,7 +40,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table { C.setTableSubclass(t.hwnd, unsafe.Pointer(t)) for i := 0; i < ty.NumField(); i++ { coltype := C.WPARAM(C.tableColumnText) - switch ty.Field(i).Type { + switch { case ty.Field(i).Type == reflect.TypeOf((*image.RGBA)(nil)): coltype = C.tableColumnImage case ty.Field(i).Type.Kind() == reflect.Bool: @@ -89,16 +90,15 @@ func tableGetCell(data unsafe.Pointer, tnm *C.tableNM) C.LRESULT { defer t.RUnlock() d := reflect.Indirect(reflect.ValueOf(t.data)) datum := d.Index(int(tnm.row)).Field(int(tnm.column)) - isText := true switch { case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)): i := datum.Interface().(*image.RGBA) - hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Dx()), C.intptr_t(i.Dy())) + hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Rect.Dx()), C.intptr_t(i.Rect.Dy())) bitmap := C.uintptr_t(uintptr(unsafe.Pointer(hbitmap))) t.freeLock.Lock() t.free[bitmap] = true // bitmap freed with C.freeBitmap() t.freeLock.Unlock() - return C.LRESULT(bmp) + return C.LRESULT(bitmap) case datum.Kind() == reflect.Bool: if datum.Bool() == true { return C.TRUE @@ -124,7 +124,7 @@ func tableFreeCellData(gotable unsafe.Pointer, data C.uintptr_t) { panic(fmt.Errorf("undefined data %p in tableFreeData()", data)) } if b == false { - C.free(data) + C.free(unsafe.Pointer(uintptr(data))) } else { C.freeBitmap(data) } diff --git a/winapi_windows.h b/winapi_windows.h index 1d10afd..49e3827 100644 --- a/winapi_windows.h +++ b/winapi_windows.h @@ -131,7 +131,7 @@ extern void areaMarkTextFieldDone(HWND); // image_windows.c extern HBITMAP toBitmap(void *, intptr_t, intptr_t); -extern void freeBitmap(void *); +extern void freeBitmap(uintptr_t); // dialog_windows.c extern void openFile(HWND, void *);