Commit c8b09927 authored by Jan Djärv's avatar Jan Djärv
Browse files

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.
parent be80645a
2013-11-04 Jan Djärv <jan.h.d@swipnet.se>
* nsterm.m (init, run, stop:): New methods in EmacsApp for
OSX >= 10.9 to prevent memory leak of GCD dispatch source.
* nsterm.h (EmacsApp): Add shouldKeepRunning and isFirst for
OSX >= 10.9.
* nsfns.m (Fx_create_frame): Fix memory leak.
* 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.
2013-11-04 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (message3_nolog, message_with_string): Encode the string
......
......@@ -624,19 +624,26 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char,
}
#define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, s) \
CGContextSetFillColorWithColor (context, \
get_cgcolor (NS_FACE_FOREGROUND (s->face), \
s->f))
do { \
CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face), \
s->f); \
CGContextSetFillColorWithColor (context, refcol_) ; \
CGColorRelease (refcol_); \
} while (0)
#define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, s) \
CGContextSetFillColorWithColor (context, \
get_cgcolor (NS_FACE_BACKGROUND (s->face), \
s->f))
do { \
CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (s->face),\
s->f); \
CGContextSetFillColorWithColor (context, refcol_); \
CGColorRelease (refcol_); \
} while (0)
#define CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND(context, s) \
CGContextSetStrokeColorWithColor (context, \
get_cgcolor (NS_FACE_FOREGROUND (s->face),\
s->f))
do { \
CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face),\
s->f); \
CGContextSetStrokeColorWithColor (context, refcol_); \
CGColorRelease (refcol_); \
} while (0)
/* Mac font driver. */
......
......@@ -1194,6 +1194,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
x_default_parameter (f, parms, Qfont,
build_string (fontname),
"font", "Font", RES_TYPE_STRING);
xfree (fontname);
}
unblock_input ();
......
......@@ -85,6 +85,10 @@ 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
BOOL shouldKeepRunning;
BOOL isFirst;
#endif
#ifdef NS_IMPL_GNUSTEP
@public
int nextappdefined;
......
......@@ -4367,6 +4367,46 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
@implementation EmacsApp
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
- (id)init
{
if (self = [super init])
self->isFirst = YES;
return self;
}
- (void)run
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
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
{
shouldKeepRunning = NO;
}
#endif
- (void)logNotification: (NSNotification *)notification
{
const char *name = [[notification name] UTF8String];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment