aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2013-11-04 18:57:17 +0100
committerJan Djärv2013-11-04 18:57:17 +0100
commitc8b09927b5ae87b19e8880614ac2b23e3c0df6e6 (patch)
treeb40122b3bc82cd4436fa5bc9c630897df6c86de3 /src
parentbe80645a9ac60598a4a7809e2be07243846b746c (diff)
downloademacs-c8b09927b5ae87b19e8880614ac2b23e3c0df6e6.tar.gz
emacs-c8b09927b5ae87b19e8880614ac2b23e3c0df6e6.zip
Fix memory leaks in NS version.
* src/macfont.m (CG_SET_FILL_COLOR_WITH_GC_FOREGROUND) (CG_SET_FILL_COLOR_WITH_GC_BACKGROUND) (CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND): Fix memory leak. * src/nsfns.m (Fx_create_frame): Fix memory leak. * src/nsterm.h (EmacsApp): Add shouldKeepRunning and isFirst for OSX >= 10.9. * src/nsterm.m (init, run, stop:): New methods in EmacsApp for OSX >= 10.9 to prevent memory leak of GCD dispatch source.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/macfont.m29
-rw-r--r--src/nsfns.m1
-rw-r--r--src/nsterm.h4
-rw-r--r--src/nsterm.m40
5 files changed, 77 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e27f83962af..5f919b8516d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12013-11-04 Jan Djärv <jan.h.d@swipnet.se>
2
3 * nsterm.m (init, run, stop:): New methods in EmacsApp for
4 OSX >= 10.9 to prevent memory leak of GCD dispatch source.
5
6 * nsterm.h (EmacsApp): Add shouldKeepRunning and isFirst for
7 OSX >= 10.9.
8
9 * nsfns.m (Fx_create_frame): Fix memory leak.
10
11 * macfont.m (CG_SET_FILL_COLOR_WITH_GC_FOREGROUND)
12 (CG_SET_FILL_COLOR_WITH_GC_BACKGROUND)
13 (CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND): Fix memory leak.
14
12013-11-04 Eli Zaretskii <eliz@gnu.org> 152013-11-04 Eli Zaretskii <eliz@gnu.org>
2 16
3 * xdisp.c (message3_nolog, message_with_string): Encode the string 17 * xdisp.c (message3_nolog, message_with_string): Encode the string
diff --git a/src/macfont.m b/src/macfont.m
index 150aca07651..4b8be551786 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -624,19 +624,26 @@ get_cgcolor(unsigned long idx, struct frame *f)
624} 624}
625 625
626#define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, s) \ 626#define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, s) \
627 CGContextSetFillColorWithColor (context, \ 627 do { \
628 get_cgcolor (NS_FACE_FOREGROUND (s->face), \ 628 CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face), \
629 s->f)) 629 s->f); \
630 630 CGContextSetFillColorWithColor (context, refcol_) ; \
631 CGColorRelease (refcol_); \
632 } while (0)
631#define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, s) \ 633#define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, s) \
632 CGContextSetFillColorWithColor (context, \ 634 do { \
633 get_cgcolor (NS_FACE_BACKGROUND (s->face), \ 635 CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (s->face),\
634 s->f)) 636 s->f); \
635 637 CGContextSetFillColorWithColor (context, refcol_); \
638 CGColorRelease (refcol_); \
639 } while (0)
636#define CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND(context, s) \ 640#define CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND(context, s) \
637 CGContextSetStrokeColorWithColor (context, \ 641 do { \
638 get_cgcolor (NS_FACE_FOREGROUND (s->face),\ 642 CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face),\
639 s->f)) 643 s->f); \
644 CGContextSetStrokeColorWithColor (context, refcol_); \
645 CGColorRelease (refcol_); \
646 } while (0)
640 647
641 648
642/* Mac font driver. */ 649/* Mac font driver. */
diff --git a/src/nsfns.m b/src/nsfns.m
index 011edf38cef..c6730f41aa7 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1194,6 +1194,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1194 x_default_parameter (f, parms, Qfont, 1194 x_default_parameter (f, parms, Qfont,
1195 build_string (fontname), 1195 build_string (fontname),
1196 "font", "Font", RES_TYPE_STRING); 1196 "font", "Font", RES_TYPE_STRING);
1197 xfree (fontname);
1197 } 1198 }
1198 unblock_input (); 1199 unblock_input ();
1199 1200
diff --git a/src/nsterm.h b/src/nsterm.h
index 71faa075f32..22a8aec9436 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -85,6 +85,10 @@ typedef float EmacsCGFloat;
85/* We override sendEvent: as a means to stop/start the event loop */ 85/* We override sendEvent: as a means to stop/start the event loop */
86@interface EmacsApp : NSApplication 86@interface EmacsApp : NSApplication
87{ 87{
88#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
89 BOOL shouldKeepRunning;
90 BOOL isFirst;
91#endif
88#ifdef NS_IMPL_GNUSTEP 92#ifdef NS_IMPL_GNUSTEP
89@public 93@public
90 int nextappdefined; 94 int nextappdefined;
diff --git a/src/nsterm.m b/src/nsterm.m
index 5ca3ab7eed2..12f182968b3 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4367,6 +4367,46 @@ ns_term_shutdown (int sig)
4367 4367
4368@implementation EmacsApp 4368@implementation EmacsApp
4369 4369
4370#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
4371- (id)init
4372{
4373 if (self = [super init])
4374 self->isFirst = YES;
4375
4376 return self;
4377}
4378
4379- (void)run
4380{
4381 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
4382
4383 if (isFirst) [self finishLaunching];
4384 isFirst = NO;
4385
4386 shouldKeepRunning = YES;
4387 do
4388 {
4389 [pool release];
4390 pool = [[NSAutoreleasePool alloc] init];
4391
4392 NSEvent *event =
4393 [self nextEventMatchingMask:NSAnyEventMask
4394 untilDate:[NSDate distantFuture]
4395 inMode:NSDefaultRunLoopMode
4396 dequeue:YES];
4397 [self sendEvent:event];
4398 [self updateWindows];
4399 } while (shouldKeepRunning);
4400
4401 [pool release];
4402}
4403
4404- (void)stop: (id)sender
4405{
4406 shouldKeepRunning = NO;
4407}
4408#endif
4409
4370- (void)logNotification: (NSNotification *)notification 4410- (void)logNotification: (NSNotification *)notification
4371{ 4411{
4372 const char *name = [[notification name] UTF8String]; 4412 const char *name = [[notification name] UTF8String];