From 21ddc8900c7281457277e795237bb56c18471f4b Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 2 Sep 2011 12:15:43 +0000 Subject: [PATCH] Before deleting a window, it's better to check whether it contains the currently focused NSView, and unlock focus there. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9026 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 8c69d4631..f7cdab7aa 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2625,7 +2625,11 @@ void Fl_X::relink(Fl_Window *w, Fl_Window *wp) { void Fl_X::destroy() { // subwindows share their xid with their parent window, so should not close it if (!subwindow && w && !w->parent() && xid) { - [[(NSWindow *)xid contentView] release]; + NSView *topview = [(NSWindow *)xid contentView]; + if ( [NSView focusView] == topview ) { + [topview unlockFocus]; + } + [topview release]; [(NSWindow *)xid close]; } }