From 0f373195de316b1b20a05ebff1463fb8a56b1f1b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 11 Feb 2014 22:41:55 -0500 Subject: Changed the sysData cache so that if we didn't fill it in yet, getSysData() returns nil instead of panicking, and the standard window procedure jumps directly to the default handler. Not what I originally wanted to do, but whatever, it finally works! --- stdwndclass_windows.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'stdwndclass_windows.go') diff --git a/stdwndclass_windows.go b/stdwndclass_windows.go index f720051..fae357a 100644 --- a/stdwndclass_windows.go +++ b/stdwndclass_windows.go @@ -16,7 +16,10 @@ var ( ) func stdWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT { -// sysData := getSysData(hwnd) + sysData := getSysData(hwnd) + if sysData == nil { // not ready for events yet + goto defwndproc + } switch uMsg { case _WM_COMMAND: id := wParam.LOWORD() @@ -32,19 +35,21 @@ func stdWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESUL // TODO return 0 case _WM_CLOSE: -/* if sysData.closing != nil { + if sysData.closing != nil { sysData.closing <- struct{}{} } -*/ return 0 + return 0 default: - r1, _, _ := defWindowProc.Call( - uintptr(hwnd), - uintptr(uMsg), - uintptr(wParam), - uintptr(lParam)) - return _LRESULT(r1) + goto defwndproc } panic(fmt.Sprintf("stdWndProc message %d did not return: internal bug in ui library", uMsg)) +defwndproc: + r1, _, _ := defWindowProc.Call( + uintptr(hwnd), + uintptr(uMsg), + uintptr(wParam), + uintptr(lParam)) + return _LRESULT(r1) } type _WNDCLASS struct { -- cgit v1.2.3