]> git.eshelyaron.com Git - emacs.git/commitdiff
Try to fix crashes introduced by 2012-09-10T21:01:45Z!jan.h.d@swipnet.se.
authorJan Djärv <jan.h.d@swipnet.se>
Sun, 16 Sep 2012 09:11:50 +0000 (11:11 +0200)
committerJan Djärv <jan.h.d@swipnet.se>
Sun, 16 Sep 2012 09:11:50 +0000 (11:11 +0200)
* 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.

src/ChangeLog
src/nsfns.m
src/nsterm.m

index c6c314b95897b14eee17bc64254677ac0efcb1d5..92117da8eb025360d679d717b2b960acc777567f 100644 (file)
@@ -1,3 +1,13 @@
+2012-09-16  Jan Djärv  <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.
+
 2012-09-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        Port _setjmp fix to POSIXish hosts as well as Microsoft.
index ed8d44014d58b63f6a7d0c32a3e5cdedefb95ffd..072005d2d3dba675890c43fdbcd1196cddf4392a 100644 (file)
@@ -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;
 }
 
index f1f23ad44792c7625d7d7ce29d4d939577d6c5ee..41520ce74d168b583789142d1a719e6c383f641d 100644 (file)
@@ -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;