mirror of
https://github.com/ziutek/glib.git
synced 2025-09-27 03:36:01 +08:00
Fixed checking of signal source type in connect method
This commit is contained in:
13
object.go
13
object.go
@@ -204,7 +204,7 @@ type sigHandler struct {
|
|||||||
var obj_handlers = make(map[uintptr]map[SigHandlerId]*sigHandler)
|
var obj_handlers = make(map[uintptr]map[SigHandlerId]*sigHandler)
|
||||||
|
|
||||||
func (o *Object) connect(noi bool, sid SignalId, detail Quark, cb_func,
|
func (o *Object) connect(noi bool, sid SignalId, detail Quark, cb_func,
|
||||||
param0 interface{}) {
|
param0 interface{}) {
|
||||||
cb := reflect.ValueOf(cb_func)
|
cb := reflect.ValueOf(cb_func)
|
||||||
if cb.Kind() != reflect.Func {
|
if cb.Kind() != reflect.Func {
|
||||||
panic("cb_func isn't a function")
|
panic("cb_func isn't a function")
|
||||||
@@ -225,6 +225,11 @@ param0 interface{}) {
|
|||||||
if noi {
|
if noi {
|
||||||
// There is no instance on which signal was emited as first parameter
|
// There is no instance on which signal was emited as first parameter
|
||||||
poffset--
|
poffset--
|
||||||
|
} else if !o.Type().Match(ft.In(poffset - 1)) {
|
||||||
|
panic(fmt.Sprintf(
|
||||||
|
"Callback #%d param. type %s doesn't match signal source: %s",
|
||||||
|
poffset-1, ft.In(poffset-1), o.Type(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
n_params := int(sq.n_params)
|
n_params := int(sq.n_params)
|
||||||
if ft.NumIn() != n_params+poffset {
|
if ft.NumIn() != n_params+poffset {
|
||||||
@@ -242,7 +247,7 @@ param0 interface{}) {
|
|||||||
if !pt[i].Match(ft.In(i + poffset)) {
|
if !pt[i].Match(ft.In(i + poffset)) {
|
||||||
panic(fmt.Sprintf(
|
panic(fmt.Sprintf(
|
||||||
"Callback #%d param. type %s doesn't match signal spec %s",
|
"Callback #%d param. type %s doesn't match signal spec %s",
|
||||||
i+1, ft.In(i+poffset), pt[i],
|
i+poffset, ft.In(i+poffset), pt[i],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,14 +281,14 @@ param0 interface{}) {
|
|||||||
|
|
||||||
// Connect callback to signal specified by id
|
// Connect callback to signal specified by id
|
||||||
func (o *Object) ConnectSid(sid SignalId, detail Quark,
|
func (o *Object) ConnectSid(sid SignalId, detail Quark,
|
||||||
cb_func, param0 interface{}) {
|
cb_func, param0 interface{}) {
|
||||||
o.connect(false, sid, detail, cb_func, param0)
|
o.connect(false, sid, detail, cb_func, param0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect callback to signal specified by id.
|
// Connect callback to signal specified by id.
|
||||||
// Doesn't pass o as first parameter to callback.
|
// Doesn't pass o as first parameter to callback.
|
||||||
func (o *Object) ConnectSidNoi(sid SignalId, detail Quark,
|
func (o *Object) ConnectSidNoi(sid SignalId, detail Quark,
|
||||||
cb_func, param0 interface{}) {
|
cb_func, param0 interface{}) {
|
||||||
o.connect(true, sid, detail, cb_func, param0)
|
o.connect(true, sid, detail, cb_func, param0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user