Fixed AppQuit on Mac OS X (forgot to set the NSApp delegate AND was using the wrong selector).

This commit is contained in:
Pietro Gagliardi 2014-04-07 12:46:09 -04:00
parent f7817f6987
commit 24d40fa12d
4 changed files with 12 additions and 10 deletions

View File

@ -336,7 +336,7 @@ void objc_setFont(id what, unsigned int csize)
extern void appDelegate_applicationShouldTerminate(); extern void appDelegate_applicationShouldTerminate();
static NSApplicationTerminateReply __appDelegate_applicationShouldTerminate(id self, SEL sel) static NSApplicationTerminateReply __appDelegate_applicationShouldTerminate(id self, SEL sel, id app)
{ {
appDelegate_applicationShouldTerminate(); appDelegate_applicationShouldTerminate();
return NSTerminateCancel; // don't quit return NSTerminateCancel; // don't quit

View File

@ -46,7 +46,7 @@ var appDelegateSels = []selector{
"handling window resize events"}, "handling window resize events"},
selector{"buttonClicked:", uintptr(C.appDelegate_buttonClicked), sel_bool_id, selector{"buttonClicked:", uintptr(C.appDelegate_buttonClicked), sel_bool_id,
"handling button clicks"}, "handling button clicks"},
selector{"applicationShouldTerminate", uintptr(C._appDelegate_applicationShouldTerminate), sel_terminatereply, selector{"applicationShouldTerminate:", uintptr(C._appDelegate_applicationShouldTerminate), sel_terminatereply_id,
"handling Quit menu items (such as from the Dock)/the AppQuit channel"}, "handling Quit menu items (such as from the Dock)/the AppQuit channel"},
} }

View File

@ -71,7 +71,7 @@ const (
sel_bool_id sel_bool_id
sel_bool sel_bool
sel_void_rect sel_void_rect
sel_terminatereply sel_terminatereply_id
nitypes nitypes
) )
@ -80,7 +80,7 @@ var itypes = [nitypes][]C.char{
sel_bool_id: []C.char{'c', '@', ':', '@', 0}, sel_bool_id: []C.char{'c', '@', ':', '@', 0},
sel_bool: []C.char{'c', '@', ':', 0}, sel_bool: []C.char{'c', '@', ':', 0},
sel_void_rect: nil, // see init() below sel_void_rect: nil, // see init() below
sel_terminatereply: nil, sel_terminatereply_id: nil,
} }
func init() { func init() {
@ -99,8 +99,8 @@ func init() {
for _, b := range y { for _, b := range y {
x = append(x, C.char(b)) x = append(x, C.char(b))
} }
x = append(x, '@', ':', 0) x = append(x, '@', ':', '@', 0)
itypes[sel_terminatereply] = x itypes[sel_terminatereply_id] = x
} }
func makeClass(name string, super C.id, sels []selector, desc string) (id C.id, err error) { func makeClass(name string, super C.id, sels []selector, desc string) (id C.id, err error) {

View File

@ -81,6 +81,7 @@ var (
_sharedApplication = sel_getUid("sharedApplication") _sharedApplication = sel_getUid("sharedApplication")
_setActivationPolicy = sel_getUid("setActivationPolicy:") _setActivationPolicy = sel_getUid("setActivationPolicy:")
_activateIgnoringOtherApps = sel_getUid("activateIgnoringOtherApps:") _activateIgnoringOtherApps = sel_getUid("activateIgnoringOtherApps:")
// _setDelegate in sysdata_darwin.go
) )
func initCocoa() (NSApp C.id, err error) { func initCocoa() (NSApp C.id, err error) {
@ -97,6 +98,7 @@ func initCocoa() (NSApp C.id, err error) {
if err != nil { if err != nil {
return return
} }
C.objc_msgSend_id(NSApp, _setDelegate, appDelegate)
err = mkAreaClass() err = mkAreaClass()
return return
} }