+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
}
#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)
\f
/* Mac font driver. */
x_default_parameter (f, parms, Qfont,
build_string (fontname),
"font", "Font", RES_TYPE_STRING);
+ xfree (fontname);
}
unblock_input ();
/* 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;
@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];