From: Jan Djärv Date: Sun, 16 Sep 2012 09:11:50 +0000 (+0200) Subject: Try to fix crashes introduced by 2012-09-10T21:01:45Z!jan.h.d@swipnet.se. X-Git-Tag: emacs-24.2.90~273^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c077c0598d5c3c7982b53946a696ec7a75c7481e;p=emacs.git Try to fix crashes introduced by 2012-09-10T21:01:45Z!jan.h.d@swipnet.se. * nsfns.m (Fx_open_connection): Move initialization of ns_*_types to ns_term_init to avoid memory leak. * nsterm.m (ns_update_begin): Initialize bp after lcokFocus, use explicit retain/release. (ns_term_init): Only allow one display. Initialize outerpool and ns_*_types. --- diff --git a/src/ChangeLog b/src/ChangeLog index c6c314b9589..92117da8eb0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2012-09-16 Jan Djärv + + * nsfns.m (Fx_open_connection): Move initialization of ns_*_types + to ns_term_init to avoid memory leak. + + * nsterm.m (ns_update_begin): Initialize bp after lcokFocus, use + explicit retain/release. + (ns_term_init): Only allow one display. Initialize outerpool and + ns_*_types. + 2012-09-15 Paul Eggert Port _setjmp fix to POSIXish hosts as well as Microsoft. diff --git a/src/nsfns.m b/src/nsfns.m index ed8d44014d5..072005d2d3d 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1796,19 +1796,6 @@ terminate Emacs if we can't open the connection. SSDATA (display)); } - /* Register our external input/output types, used for determining - applicable services and also drag/drop eligibility. */ - ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; - ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] - retain]; - ns_drag_types = [[NSArray arrayWithObjects: - NSStringPboardType, - NSTabularTextPboardType, - NSFilenamesPboardType, - NSURLPboardType, - NSColorPboardType, - NSFontPboardType, nil] retain]; - return Qnil; } diff --git a/src/nsterm.m b/src/nsterm.m index f1f23ad4479..41520ce74d1 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -627,7 +627,7 @@ ns_update_begin (struct frame *f) { NSView *view = FRAME_NS_VIEW (f); NSRect r = [view frame]; - NSBezierPath *bp = [NSBezierPath bezierPath]; + NSBezierPath *bp; NSTRACE (ns_update_begin); ns_update_auto_hide_menu_bar (); @@ -639,8 +639,9 @@ ns_update_begin (struct frame *f) is for the minibuffer. But the display engine may draw more because we have set the frame as garbaged. So reset clip path to the whole view. */ - [bp appendBezierPathWithRect: r]; + bp = [[NSBezierPath bezierPathWithRect: r] retain]; [bp setClip]; + [bp release]; #ifdef NS_IMPL_GNUSTEP uRect = NSMakeRect (0, 0, 0, 0); @@ -3976,33 +3977,35 @@ ns_term_init (Lisp_Object display_name) static int ns_initialized = 0; Lisp_Object tmp; + if (ns_initialized) return x_display_list; + ns_initialized = 1; + NSTRACE (ns_term_init); + [outerpool release]; + outerpool = [[NSAutoreleasePool alloc] init]; + /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */ /*GSDebugAllocationActive (YES); */ BLOCK_INPUT; handling_signal = 0; - if (!ns_initialized) - { - baud_rate = 38400; - Fset_input_interrupt_mode (Qnil); + baud_rate = 38400; + Fset_input_interrupt_mode (Qnil); - if (selfds[0] == -1) + if (selfds[0] == -1) + { + if (pipe (selfds) == -1) { - if (pipe (selfds) == -1) - { - fprintf (stderr, "Failed to create pipe: %s\n", - emacs_strerror (errno)); - emacs_abort (); - } - - fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); - FD_ZERO (&select_readfds); - FD_ZERO (&select_writefds); - pthread_mutex_init (&select_mutex, NULL); + fprintf (stderr, "Failed to create pipe: %s\n", + emacs_strerror (errno)); + emacs_abort (); } - ns_initialized = 1; + + fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); + FD_ZERO (&select_readfds); + FD_ZERO (&select_writefds); + pthread_mutex_init (&select_mutex, NULL); } ns_pending_files = [[NSMutableArray alloc] init]; @@ -4193,6 +4196,20 @@ ns_term_init (Lisp_Object display_name) } #endif /* MAC OS X menu setup */ + /* Register our external input/output types, used for determining + applicable services and also drag/drop eligibility. */ + ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; + ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] + retain]; + ns_drag_types = [[NSArray arrayWithObjects: + NSStringPboardType, + NSTabularTextPboardType, + NSFilenamesPboardType, + NSURLPboardType, + NSColorPboardType, + NSFontPboardType, nil] retain]; + + [NSApp run]; ns_do_open_file = YES; return dpyinfo;