diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-30 09:57:44 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-30 09:57:44 -0400 |
| commit | 33155f7496a818a1ed83fe49cccb63be7842bc81 (patch) | |
| tree | bbb14af3d92becf7d5ca5abfb28630a2b413ad93 /area.go | |
| parent | e032807546a96e6489d18a0e42ced51b7c31a55c (diff) | |
Reverted everything back to the old API.
Diffstat (limited to 'area.go')
| -rw-r--r-- | area.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -6,6 +6,7 @@ import ( "fmt" "image" "reflect" + "sync" "unsafe" ) @@ -27,6 +28,7 @@ import ( // to lead to trouble. // [FOR FUTURE PLANNING Use TextArea instead, providing a TextAreaHandler.] type Area struct { + lock sync.Mutex created bool sysData *sysData handler AreaHandler @@ -296,6 +298,9 @@ func NewArea(width int, height int, handler AreaHandler) *Area { // SetSize will also signal the entirety of the Area to be redrawn as in RepaintAll. // It panics if width or height is zero or negative. func (a *Area) SetSize(width int, height int) { + a.lock.Lock() + defer a.lock.Unlock() + checkAreaSize(width, height, "Area.SetSize()") if a.created { a.sysData.setAreaSize(width, height) @@ -308,6 +313,9 @@ func (a *Area) SetSize(width int, height int) { // RepaintAll signals the entirety of the Area for redraw. // If called before the Window containing the Area is created, RepaintAll does nothing. func (a *Area) RepaintAll() { + a.lock.Lock() + defer a.lock.Unlock() + if !a.created { return } @@ -315,6 +323,9 @@ func (a *Area) RepaintAll() { } func (a *Area) make(window *sysData) error { + a.lock.Lock() + defer a.lock.Unlock() + a.sysData.handler = a.handler err := a.sysData.make(window) if err != nil { |
