]> code.delx.au - gnu-emacs/commitdiff
Fix memory leaks
authorJan Djärv <jan.h.d@swipnet.se>
Wed, 11 Jun 2014 17:57:51 +0000 (19:57 +0200)
committerJan Djärv <jan.h.d@swipnet.se>
Wed, 11 Jun 2014 17:57:51 +0000 (19:57 +0200)
* macfont.m (macfont_draw): positions where not freed.

* nsterm.h (EmacsApp): Always compile in shouldKeepRunning, isFirst
on Cocoa.

* nsterm.m (run): Always compile for Cocoa.  Use runtime check to
determine 10.9.

Fixes: debbugs:17751
src/ChangeLog
src/macfont.m
src/nsterm.h
src/nsterm.m

index 5fec848154b26c6dc7a469501574841887ab4dc7..6733cf176caa6080fc4431506e456213e07d5397 100644 (file)
@@ -1,3 +1,13 @@
+2014-06-11  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * nsterm.h (EmacsApp): Always compile in shouldKeepRunning, isFirst
+       on Cocoa.
+
+       * nsterm.m (run): Always compile for Cocoa.  Use runtime check to
+       determine 10.9 (Bug#17751).
+
+       * macfont.m (macfont_draw): positions where not freed.
+
 2014-06-10  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * dispextern.h (PREPARE_FACE_FOR_DISPLAY): Remove as a duplicate of ...
index d34e03322367aafeec4acb4fb017e1629431c676..9b3cb2c29f653eb8fe1b1c4b94105979cb24b5c3 100644 (file)
@@ -2810,6 +2810,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
 
 
   xfree (glyphs);
+  xfree (positions);
   CGContextRestoreGState (context);
 
   unblock_input ();
index d2c42c553d9211b4fee25d91659e2697a599e05c..e77aca3d50d263e84c3ea1c5a377669be2f28637 100644 (file)
@@ -100,7 +100,7 @@ typedef float EmacsCGFloat;
 /* We override sendEvent: as a means to stop/start the event loop */
 @interface EmacsApp : NSApplication
 {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+#ifdef NS_IMPL_COCOA
   BOOL shouldKeepRunning;
   BOOL isFirst;
 #endif
index 6b617be4c0d31bd0f1592c5da84b68bec5bbdf5d..c6450804f577701db44d1e5e6319dcfcf45daad0 100644 (file)
@@ -4453,7 +4453,7 @@ ns_term_shutdown (int sig)
 {
   if (self = [super init])
     {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+#ifdef NS_IMPL_COCOA
       self->isFirst = YES;
 #endif
 #ifdef NS_IMPL_GNUSTEP
@@ -4464,30 +4464,40 @@ ns_term_shutdown (int sig)
   return self;
 }
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+#ifdef NS_IMPL_COCOA
 - (void)run
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#ifndef NSAppKitVersionNumber10_8
+#define NSAppKitVersionNumber10_8 1187
+#endif
 
-    if (isFirst) [self finishLaunching];
-    isFirst = NO;
+  if (NSAppKitVersionNumber <= NSAppKitVersionNumber10_8) 
+    {
+      [super run];
+      return;
+    }
 
-    shouldKeepRunning = YES;
-    do
-      {
-        [pool release];
-        pool = [[NSAutoreleasePool alloc] init];
-
-        NSEvent *event =
-          [self nextEventMatchingMask:NSAnyEventMask
-                            untilDate:[NSDate distantFuture]
-                               inMode:NSDefaultRunLoopMode
-                              dequeue:YES];
-        [self sendEvent:event];
-        [self updateWindows];
-    } while (shouldKeepRunning);
+  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
-    [pool release];
+  if (isFirst) [self finishLaunching];
+  isFirst = NO;
+
+  shouldKeepRunning = YES;
+  do
+    {
+      [pool release];
+      pool = [[NSAutoreleasePool alloc] init];
+
+      NSEvent *event =
+        [self nextEventMatchingMask:NSAnyEventMask
+                          untilDate:[NSDate distantFuture]
+                             inMode:NSDefaultRunLoopMode
+                            dequeue:YES];
+      [self sendEvent:event];
+      [self updateWindows];
+    } while (shouldKeepRunning);
+  
+  [pool release];
 }
 
 - (void)stop: (id)sender
@@ -4497,7 +4507,7 @@ ns_term_shutdown (int sig)
     // The file dialog still leaks 7k - 10k on 10.9 though.
     [super stop:sender];
 }
-#endif
+#endif /* NS_IMPL_COCOA */
 
 - (void)logNotification: (NSNotification *)notification
 {