aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2012-09-16 11:11:50 +0200
committerJan Djärv2012-09-16 11:11:50 +0200
commitc077c0598d5c3c7982b53946a696ec7a75c7481e (patch)
tree2d2bf63d1c3feb7b6daa768590dbe6ec23190ead /src
parent71ce58e752dfb8d384eddf2d40ee9d5861ede5e5 (diff)
downloademacs-c077c0598d5c3c7982b53946a696ec7a75c7481e.tar.gz
emacs-c077c0598d5c3c7982b53946a696ec7a75c7481e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/nsfns.m13
-rw-r--r--src/nsterm.m55
3 files changed, 46 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c6c314b9589..92117da8eb0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12012-09-16 Jan Djärv <jan.h.d@swipnet.se>
2
3 * nsfns.m (Fx_open_connection): Move initialization of ns_*_types
4 to ns_term_init to avoid memory leak.
5
6 * nsterm.m (ns_update_begin): Initialize bp after lcokFocus, use
7 explicit retain/release.
8 (ns_term_init): Only allow one display. Initialize outerpool and
9 ns_*_types.
10
12012-09-15 Paul Eggert <eggert@cs.ucla.edu> 112012-09-15 Paul Eggert <eggert@cs.ucla.edu>
2 12
3 Port _setjmp fix to POSIXish hosts as well as Microsoft. 13 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.
1796 SSDATA (display)); 1796 SSDATA (display));
1797 } 1797 }
1798 1798
1799 /* Register our external input/output types, used for determining
1800 applicable services and also drag/drop eligibility. */
1801 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
1802 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
1803 retain];
1804 ns_drag_types = [[NSArray arrayWithObjects:
1805 NSStringPboardType,
1806 NSTabularTextPboardType,
1807 NSFilenamesPboardType,
1808 NSURLPboardType,
1809 NSColorPboardType,
1810 NSFontPboardType, nil] retain];
1811
1812 return Qnil; 1799 return Qnil;
1813} 1800}
1814 1801
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)
627{ 627{
628 NSView *view = FRAME_NS_VIEW (f); 628 NSView *view = FRAME_NS_VIEW (f);
629 NSRect r = [view frame]; 629 NSRect r = [view frame];
630 NSBezierPath *bp = [NSBezierPath bezierPath]; 630 NSBezierPath *bp;
631 NSTRACE (ns_update_begin); 631 NSTRACE (ns_update_begin);
632 632
633 ns_update_auto_hide_menu_bar (); 633 ns_update_auto_hide_menu_bar ();
@@ -639,8 +639,9 @@ ns_update_begin (struct frame *f)
639 is for the minibuffer. But the display engine may draw more because 639 is for the minibuffer. But the display engine may draw more because
640 we have set the frame as garbaged. So reset clip path to the whole 640 we have set the frame as garbaged. So reset clip path to the whole
641 view. */ 641 view. */
642 [bp appendBezierPathWithRect: r]; 642 bp = [[NSBezierPath bezierPathWithRect: r] retain];
643 [bp setClip]; 643 [bp setClip];
644 [bp release];
644 645
645#ifdef NS_IMPL_GNUSTEP 646#ifdef NS_IMPL_GNUSTEP
646 uRect = NSMakeRect (0, 0, 0, 0); 647 uRect = NSMakeRect (0, 0, 0, 0);
@@ -3976,33 +3977,35 @@ ns_term_init (Lisp_Object display_name)
3976 static int ns_initialized = 0; 3977 static int ns_initialized = 0;
3977 Lisp_Object tmp; 3978 Lisp_Object tmp;
3978 3979
3980 if (ns_initialized) return x_display_list;
3981 ns_initialized = 1;
3982
3979 NSTRACE (ns_term_init); 3983 NSTRACE (ns_term_init);
3980 3984
3985 [outerpool release];
3986 outerpool = [[NSAutoreleasePool alloc] init];
3987
3981 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */ 3988 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */
3982 /*GSDebugAllocationActive (YES); */ 3989 /*GSDebugAllocationActive (YES); */
3983 BLOCK_INPUT; 3990 BLOCK_INPUT;
3984 handling_signal = 0; 3991 handling_signal = 0;
3985 3992
3986 if (!ns_initialized) 3993 baud_rate = 38400;
3987 { 3994 Fset_input_interrupt_mode (Qnil);
3988 baud_rate = 38400;
3989 Fset_input_interrupt_mode (Qnil);
3990 3995
3991 if (selfds[0] == -1) 3996 if (selfds[0] == -1)
3997 {
3998 if (pipe (selfds) == -1)
3992 { 3999 {
3993 if (pipe (selfds) == -1) 4000 fprintf (stderr, "Failed to create pipe: %s\n",
3994 { 4001 emacs_strerror (errno));
3995 fprintf (stderr, "Failed to create pipe: %s\n", 4002 emacs_abort ();
3996 emacs_strerror (errno));
3997 emacs_abort ();
3998 }
3999
4000 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL));
4001 FD_ZERO (&select_readfds);
4002 FD_ZERO (&select_writefds);
4003 pthread_mutex_init (&select_mutex, NULL);
4004 } 4003 }
4005 ns_initialized = 1; 4004
4005 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL));
4006 FD_ZERO (&select_readfds);
4007 FD_ZERO (&select_writefds);
4008 pthread_mutex_init (&select_mutex, NULL);
4006 } 4009 }
4007 4010
4008 ns_pending_files = [[NSMutableArray alloc] init]; 4011 ns_pending_files = [[NSMutableArray alloc] init];
@@ -4193,6 +4196,20 @@ ns_term_init (Lisp_Object display_name)
4193 } 4196 }
4194#endif /* MAC OS X menu setup */ 4197#endif /* MAC OS X menu setup */
4195 4198
4199 /* Register our external input/output types, used for determining
4200 applicable services and also drag/drop eligibility. */
4201 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
4202 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
4203 retain];
4204 ns_drag_types = [[NSArray arrayWithObjects:
4205 NSStringPboardType,
4206 NSTabularTextPboardType,
4207 NSFilenamesPboardType,
4208 NSURLPboardType,
4209 NSColorPboardType,
4210 NSFontPboardType, nil] retain];
4211
4212
4196 [NSApp run]; 4213 [NSApp run];
4197 ns_do_open_file = YES; 4214 ns_do_open_file = YES;
4198 return dpyinfo; 4215 return dpyinfo;