Removed the mutexes from Labels and Areas because I'm at my wits end about settling the deadlock between window resizing and setting a Label's text.
This commit is contained in:
parent
7c3647712b
commit
4adf1ae5cd
|
@ -1,5 +1,7 @@
|
|||
[![Build Status](https://travis-ci.org/andlabs/ui.png?branch=master)](https://travis-ci.org/andlabs/ui)
|
||||
# Native UI library for Go
|
||||
### CRITICAL UPDATE 17 March 2014: Due to deadlocks between resizing and setting label text once a second, Labels and Areas do not lock their internal mutex locks after their Window has been created. This seems to not have issues, and the Go race detector isn't saying anything, so IDK... Please help with this if you can. I will have to remove the mutexes from the other classes (later) to make this work properly.
|
||||
|
||||
### THIS PACKAGE IS UNDER ACTIVE DEVELOPMENT. It can be used; the API is stable enough at this point, but keep in mind there may still be crashes and API changes, as suggestions are always open. If you can help, please do! Run `./test` to build a test binary `test/test` which runs a (mostly) feature-complete UI test. Run `./d32 ./test` to build a 32-bit version (you will need a cgo-enabled 32-bit go environment, and I have only tested this on Mac OS X).
|
||||
|
||||
### UPDATE 12 March 2014: Windows 2000 is no longer supported [as it is no longer supported by Go](https://codereview.appspot.com/74790043).
|
||||
|
|
6
area.go
6
area.go
|
@ -122,15 +122,9 @@ func (a *Area) make(window *sysData) error {
|
|||
}
|
||||
|
||||
func (a *Area) setRect(x int, y int, width int, height int, winheight int) error {
|
||||
a.lock.Lock()
|
||||
defer a.lock.Unlock()
|
||||
|
||||
return a.sysData.setRect(x, y, width, height, winheight)
|
||||
}
|
||||
|
||||
func (a *Area) preferredSize() (width int, height int) {
|
||||
a.lock.Lock()
|
||||
defer a.lock.Unlock()
|
||||
|
||||
return a.sysData.preferredSize()
|
||||
}
|
||||
|
|
16
label.go
16
label.go
|
@ -24,24 +24,22 @@ func NewLabel(text string) *Label {
|
|||
|
||||
// SetText sets the Label's text.
|
||||
func (l *Label) SetText(text string) {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
if l.created {
|
||||
l.sysData.setText(text)
|
||||
return
|
||||
}
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
l.initText = text
|
||||
}
|
||||
|
||||
// Text returns the Label's text.
|
||||
func (l *Label) Text() string {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
if l.created {
|
||||
return l.sysData.text()
|
||||
}
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
return l.initText
|
||||
}
|
||||
|
||||
|
@ -58,15 +56,9 @@ func (l *Label) make(window *sysData) error {
|
|||
}
|
||||
|
||||
func (l *Label) setRect(x int, y int, width int, height int, winheight int) error {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
return l.sysData.setRect(x, y, width, height, winheight)
|
||||
}
|
||||
|
||||
func (l *Label) preferredSize() (width int, height int) {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
return l.sysData.preferredSize()
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ type areaHandler struct {
|
|||
img *image.NRGBA
|
||||
}
|
||||
func (a *areaHandler) Paint(rect image.Rectangle) *image.NRGBA {
|
||||
fmt.Println(rect)
|
||||
//fmt.Println(rect)
|
||||
/*
|
||||
req.Out <- img[i].SubImage(req.Rect).(*image.NRGBA)
|
||||
if lastrect != req.Rect {
|
||||
|
@ -131,7 +131,7 @@ fmt.Println(rect)
|
|||
return a.img.SubImage(rect).(*image.NRGBA)
|
||||
}
|
||||
func (a *areaHandler) Mouse(e MouseEvent) {
|
||||
fmt.Printf("%#v\n", e)
|
||||
// fmt.Printf("%#v\n", e)
|
||||
}
|
||||
|
||||
var doArea = flag.Bool("area", false, "run area test instead")
|
||||
|
|
Loading…
Reference in New Issue