Fixed the GTK+ crashes (I think) by making resizes synchronous. Since all control resizes happen on the UI thread anyway, we don't need to dispatch back; just call the resizing functions directly. Windows gets this fix too for consistency (and also because it gets rid of the only asynchronous oddity in the system).

This commit is contained in:
Pietro Gagliardi 2014-02-17 01:40:53 -05:00
parent 0856e953be
commit 0595135d9a
3 changed files with 20 additions and 36 deletions

View File

@ -51,13 +51,10 @@ func stdWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam
if r1 == 0 {
panic("GetClientRect failed: " + err.Error())
}
// run the resize in a goroutine, since the WndProc is being run on uitask
go func() {
err = s.resize(int(r.Left), int(r.Top), int(r.Right), int(r.Bottom))
if err != nil {
panic("child resize failed: " + err.Error())
}
}()
err = s.resize(int(r.Left), int(r.Top), int(r.Right), int(r.Bottom))
if err != nil {
panic("child resize failed: " + err.Error())
}
}
return 0
case _WM_CLOSE:

View File

@ -48,12 +48,13 @@ var classTypes = [nctypes]*classData{
return func() bool {
if w.container != nil && w.resize != nil { // wait for init
width, height := gtk_window_get_size(w.widget)
// run in another goroutine since this will be called in uitask
go func() {
w.resize(0, 0, width, height)
}()
err := w.resize(0, 0, width, height)
if err != nil {
panic("child resize failed: " + err.Error())
}
}
// returning false indicates that we continue processing events related to configure-event; if we choose not to, then after some controls have been added, the layout fails completely and everything stays in the starting position/size
// TODO make sure this is the case
return false
}
},
@ -198,14 +199,8 @@ func (s *sysData) setText(text string) error {
}
func (s *sysData) setRect(x int, y int, width int, height int) error {
ret := make(chan struct{})
defer close(ret)
uitask <- func() {
gtk_fixed_move(s.container, s.widget, x, y)
gtk_widget_set_size_request(s.widget, width, height)
ret <- struct{}{}
}
<-ret
gtk_fixed_move(s.container, s.widget, x, y)
gtk_widget_set_size_request(s.widget, width, height)
return nil
}

View File

@ -226,23 +226,15 @@ func (s *sysData) setText(text string) error {
}
func (s *sysData) setRect(x int, y int, width int, height int) error {
ret := make(chan uiret)
defer close(ret)
uitask <- &uimsg{
call: _moveWindow,
p: []uintptr{
uintptr(s.hwnd),
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height),
uintptr(_TRUE),
},
ret: ret,
}
r := <-ret
if r.ret == 0 { // failure
return fmt.Errorf("error setting window/control rect: %v", r.err)
r1, _, err := _moveWindow.Call(
uintptr(s.hwnd),
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height),
uintptr(_TRUE))
if r1 == 0 { // failure
return fmt.Errorf("error setting window/control rect: %v", err)
}
return nil
}