summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-11 13:50:02 -0400
committerPietro Gagliardi <[email protected]>2014-03-11 13:50:02 -0400
commit92fb9efce9d9f84e06f574243218e3c6d7478d18 (patch)
tree8dab00a7dd655e9dd04008da50e6eb38bbdd939d
parentc43583fe20a3a54920774fb762c74d22b60b70dc (diff)
Removed error returns from Combobox.Delete(), Listbox.Delete(), and sysData.delete(), since they are no longer used. Updated the TODO file to mark this issue closed.
-rw-r--r--combobox.go7
-rw-r--r--listbox.go7
-rw-r--r--sysdata.go2
-rw-r--r--sysdata_darwin.go3
-rw-r--r--sysdata_unix.go3
-rw-r--r--sysdata_windows.go5
-rw-r--r--todo.md3
7 files changed, 14 insertions, 16 deletions
diff --git a/combobox.go b/combobox.go
index 85384be..009e639 100644
--- a/combobox.go
+++ b/combobox.go
@@ -78,7 +78,7 @@ badrange:
}
// Delete removes the given item from the Combobox. It panics if the given index is out of bounds.
-func (c *Combobox) Delete(index int) error {
+func (c *Combobox) Delete(index int) {
c.lock.Lock()
defer c.lock.Unlock()
@@ -86,13 +86,14 @@ func (c *Combobox) Delete(index int) error {
if index < 0 || index >= c.sysData.len() {
goto badrange
}
- return c.sysData.delete(index)
+ c.sysData.delete(index)
+ return
}
if index < 0 || index >= len(c.initItems) {
goto badrange
}
c.initItems = append(c.initItems[:index], c.initItems[index + 1:]...)
- return nil
+ return
badrange:
panic(fmt.Errorf("index %d out of range in Combobox.Delete()", index))
}
diff --git a/listbox.go b/listbox.go
index 63f8722..7e05287 100644
--- a/listbox.go
+++ b/listbox.go
@@ -70,7 +70,7 @@ badrange:
}
// Delete removes the given item from the Listbox. It panics if the given index is out of bounds.
-func (l *Listbox) Delete(index int) error {
+func (l *Listbox) Delete(index int) {
l.lock.Lock()
defer l.lock.Unlock()
@@ -78,13 +78,14 @@ func (l *Listbox) Delete(index int) error {
if index < 0 || index >= l.sysData.len() {
goto badrange
}
- return l.sysData.delete(index)
+ l.sysData.delete(index)
+ return
}
if index < 0 || index >= len(l.initItems) {
goto badrange
}
l.initItems = append(l.initItems[:index], l.initItems[index + 1:]...)
- return nil
+ return
badrange:
panic(fmt.Errorf("index %d out of range in Listbox.Delete()", index))
}
diff --git a/sysdata.go b/sysdata.go
index a942122..2680269 100644
--- a/sysdata.go
+++ b/sysdata.go
@@ -61,7 +61,7 @@ func (c *cSysData) selectedTexts() []string {
func (c *cSysData) setWindowSize(int, int) error {
panic(runtime.GOOS + " sysData does not define setWindowSize()")
}
-func (c *cSysData) delete(int) error {
+func (c *cSysData) delete(int) {
panic(runtime.GOOS + " sysData does not define delete()")
}
func (c *cSysData) preferredSize() (int, int) {
diff --git a/sysdata_darwin.go b/sysdata_darwin.go
index 32b94c3..85b6c73 100644
--- a/sysdata_darwin.go
+++ b/sysdata_darwin.go
@@ -449,7 +449,7 @@ func (s *sysData) setWindowSize(width int, height int) error {
return nil
}
-func (s *sysData) delete(index int) error {
+func (s *sysData) delete(index int) {
ret := make(chan struct{})
defer close(ret)
uitask <- func() {
@@ -457,7 +457,6 @@ func (s *sysData) delete(index int) error {
ret <- struct{}{}
}
<-ret
- return nil
}
func (s *sysData) setProgress(percent int) {
diff --git a/sysdata_unix.go b/sysdata_unix.go
index a910df7..6947e20 100644
--- a/sysdata_unix.go
+++ b/sysdata_unix.go
@@ -275,7 +275,7 @@ func (s *sysData) setWindowSize(width int, height int) error {
return nil
}
-func (s *sysData) delete(index int) error {
+func (s *sysData) delete(index int) {
ret := make(chan struct{})
defer close(ret)
uitask <- func() {
@@ -283,7 +283,6 @@ func (s *sysData) delete(index int) error {
ret <- struct{}{}
}
<-ret
- return nil
}
func (s *sysData) setProgress(percent int) {
diff --git a/sysdata_windows.go b/sysdata_windows.go
index 62c5788..3cc5730 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -494,7 +494,7 @@ func (s *sysData) setWindowSize(width int, height int) error {
return nil
}
-func (s *sysData) delete(index int) (err error) {
+func (s *sysData) delete(index int) {
ret := make(chan uiret)
defer close(ret)
uitask <- &uimsg{
@@ -509,9 +509,8 @@ func (s *sysData) delete(index int) (err error) {
}
r := <-ret
if r.ret == uintptr(classTypes[s.ctype].selectedIndexErr) {
- return fmt.Errorf("failed to delete item from combobox/listbox (last error: %v)", r.err)
+ panic(fmt.Errorf("failed to delete item from combobox/listbox (last error: %v)", r.err))
}
- return nil
}
func (s *sysData) setProgress(percent int) {
diff --git a/todo.md b/todo.md
index ec02400..87d5c76 100644
--- a/todo.md
+++ b/todo.md
@@ -17,8 +17,7 @@ so I don't forget:
- Combobox/Listbox.Select (with Listbox.Select allowing bulk)
- Checkbox.Check or Checkbox.SetChecked
- Listbox.SelectAll
-- have Listbox.Delete() panic on invalid index; it does not yet due to the Mac OS X signaling issue mentioned under "super important"
- - same for other methods that take indices, like the Stack and Grid stretchy methods
+- have methods that take indices panic on invalid index, like the Stack and Grid stretchy methods
- make the Windows implementation of message boxes run on uitask
- ensure MsgBoxError can run if initialization failed if things change ever
- should Labels be selectable?