* emacs.c (ns_pool): New variable.
(main): Assign ns_pool.
(Fkill_emacs): Call ns_release_autorelease_pool.
* nsfns.m (x_set_background_color): Assign return value from
ns_index_color to face-background instead of NSColor*.
(ns_implicitly_set_icon_type): Fix indentation.
Change assignment in for loop to comparison.
* nsfont.m (ns_spec_to_descriptor): Fix indentation,
autorelease fdesc, release fdAttrs and tdict.
(ns_get_covering_families): Release charset.
(ns_findfonts): Release NSFontDescriptor created with new.
(ns_uni_to_glyphs): Fix indentation.
(setString): Release attrStr before assigning new value.
* nsmenu.m (ns_update_menubar): Call free_menubar_widget_value_tree
before returning.
* nsterm.m (x_free_frame_resources): Release
f->output_data.ns->miniimage
(ns_index_color): Fix indentation. Do not retain
color_table->colors[i].
+2011-12-21 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsterm.m (x_free_frame_resources): Release
+ f->output_data.ns->miniimage
+ (ns_index_color): Fix indentation. Do not retain
+ color_table->colors[i].
+
+ * nsmenu.m (ns_update_menubar): Call free_menubar_widget_value_tree
+ before returning.
+
+ * nsfns.m (x_set_background_color): Assign return value from
+ ns_index_color to face-background instead of NSColor*.
+ (ns_implicitly_set_icon_type): Fix indentation.
+ Change assignment in for loop to comparison.
+
+ * emacs.c (ns_pool): New variable.
+ (main): Assign ns_pool.
+ (Fkill_emacs): Call ns_release_autorelease_pool.
+
+ * nsfont.m (ns_spec_to_descriptor): Fix indentation,
+ autorelease fdesc, release fdAttrs and tdict.
+ (ns_get_covering_families): Release charset.
+ (ns_findfonts): Release NSFontDescriptor created with new.
+ (ns_uni_to_glyphs): Fix indentation.
+ (setString): Release attrStr before assigning new value.
+
2011-12-18 Jan Djärv <jan.h.d@swipnet.se>
* nsmenu.m (NSMenuDidBeginTrackingNotification): Declare if OSX < 10.5
pthread_t main_thread;
#endif
+#ifdef HAVE_NS
+/* NS autrelease pool, for memory management. */
+static void *ns_pool;
+#endif
+
+
/* Handle bus errors, invalid instruction, etc. */
#ifndef FLOAT_CATCH_SIGILL
= argmatch (argv, argc, "-nsl", "--no-site-lisp", 11, NULL, &skip_args);
#ifdef HAVE_NS
- ns_alloc_autorelease_pool ();
+ ns_pool = ns_alloc_autorelease_pool ();
if (!noninteractive)
{
#ifdef NS_IMPL_COCOA
shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
+#ifdef HAVE_NS
+ ns_release_autorelease_pool (ns_pool);
+#endif
+
/* If we have an auto-save list file,
kill it because we are exiting Emacs deliberately (not crashing).
Do it after shut_down_emacs, which does an auto-save. */
if (face)
{
col = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f);
- face->background
- = (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
- [col release];
+ face->background = ns_index_color
+ ([col colorWithAlphaComponent: alpha], f);
update_face_from_frame_parameter (f, Qbackground_color, arg);
}
{
Lisp_Object tem;
EmacsView *view = FRAME_NS_VIEW (f);
- id image =nil;
+ id image = nil;
Lisp_Object chain, elt;
NSAutoreleasePool *pool;
BOOL setMini = YES;
}
for (chain = Vns_icon_type_alist;
- (image = nil) && CONSP (chain);
+ image == nil && CONSP (chain);
chain = XCDR (chain))
{
elt = XCAR (chain);
/* Converts FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, plus family and script/lang
to NSFont descriptor. Information under extra only needed for matching. */
#define STYLE_REF 100
-static NSFontDescriptor
-*ns_spec_to_descriptor(Lisp_Object font_spec)
+static NSFontDescriptor *
+ns_spec_to_descriptor (Lisp_Object font_spec)
{
NSFontDescriptor *fdesc;
NSMutableDictionary *fdAttrs = [NSMutableDictionary new];
[fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs];
- if (family != nil)
+ if (family != nil)
+ {
fdesc = [fdesc fontDescriptorWithFamily: family];
+ [fdesc autorelease];
+ }
+
+ [fdAttrs release];
+ [tdict release];
return fdesc;
}
if ([families count] > 0 || pct < 0.05)
break;
}
+ [charset release];
}
#ifdef NS_IMPL_COCOA
if ([families count] == 0)
family = [fdesc objectForKey: NSFontFamilyAttribute];
if (family != nil && !foundItal && XINT (Flength (list)) > 0)
{
- NSFontDescriptor *sDesc = [[[NSFontDescriptor new]
- fontDescriptorWithSymbolicTraits: NSFontItalicTrait]
- fontDescriptorWithFamily: family];
+ NSFontDescriptor *s1 = [NSFontDescriptor new];
+ NSFontDescriptor *sDesc
+ = [[s1 fontDescriptorWithSymbolicTraits: NSFontItalicTrait]
+ fontDescriptorWithFamily: family];
list = Fcons (ns_descriptor_to_entity (sDesc,
AREF (font_spec, FONT_EXTRA_INDEX),
"synthItal"), list);
+ [s1 release];
}
/* Return something if was a match and nothing found. */
abort ();
/* create a string containing all Unicode characters in this block */
- for (idx = block<<8, i =0; i<0x100; idx++, i++)
+ for (idx = block<<8, i = 0; i < 0x100; idx++, i++)
if (idx < 0xD800 || idx > 0xDFFF)
unichars[i] = idx;
else
NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator];
/*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */
unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs];
- NSUInteger gInd =0, cInd =0;
+ NSUInteger gInd = 0, cInd = 0;
[glyphStorage setString: allChars font: font_info->nsfont];
[glyphGenerator generateGlyphsForGlyphStorage: glyphStorage
glyphIndex: &gInd characterIndex: &cInd];
#endif
glyphs = font_info->glyphs[block];
- for (i =0; i<0x100; i++, glyphs++)
+ for (i = 0; i < 0x100; i++, glyphs++)
{
#ifdef NS_IMPL_GNUSTEP
g = unichars[i];
- (void) setString: (NSString *)str font: (NSFont *)font
{
[dict setObject: font forKey: NSFontAttributeName];
+ if (attrStr != nil)
+ [attrStr release];
attrStr = [[NSAttributedString alloc] initWithString: str attributes: dict];
maxChar = [str length];
maxGlyph = 0;
items = FRAME_MENU_BAR_ITEMS (f);
if (NILP (items))
{
+ free_menubar_widget_value_tree (first_wv);
[pool release];
UNBLOCK_INPUT;
return;
if (i == n)
{
+ free_menubar_widget_value_tree (first_wv);
[pool release];
UNBLOCK_INPUT;
return;
xfree (f->output_data.ns);
+ if (f->output_data.ns->miniimage != nil)
+ [f->output_data.ns->miniimage release];
+
[[view window] close];
[view release];
{
struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
ptrdiff_t idx;
- NSNumber *index;
+ ptrdiff_t i;
if (!color_table->colors)
{
}
/* do we already have this color ? */
- {
- ptrdiff_t i;
- for (i = 1; i < color_table->avail; i++)
- {
- if (color_table->colors[i] && [color_table->colors[i] isEqual: color])
- {
- [color_table->colors[i] retain];
- return i;
- }
- }
- }
+ for (i = 1; i < color_table->avail; i++)
+ if (color_table->colors[i] && [color_table->colors[i] isEqual: color])
+ return i;
if ([color_table->empty_indices count] > 0)
{
- index = [color_table->empty_indices anyObject];
+ NSNumber *index = [color_table->empty_indices anyObject];
[color_table->empty_indices removeObject: index];
idx = [index unsignedLongValue];
}
color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
if (idx <= 0 || idx >= color_table->size) {
- message1("ns_free_indexed_color: Color index out of range.\n");
+ message1 ("ns_free_indexed_color: Color index out of range.\n");
return;
}
index = [NSNumber numberWithUnsignedInt: idx];
if ([color_table->empty_indices containsObject: index]) {
- message1("ns_free_indexed_color: attempt to free already freed color.\n");
+ message1 ("ns_free_indexed_color: attempt to free already freed color.\n");
return;
}
color = color_table->colors[idx];
[color release];
color_table->colors[idx] = nil;
- [color_table->empty_indices addObject: [NSNumber numberWithUnsignedInt: idx]];
+ [color_table->empty_indices addObject: index];
/*fprintf(stderr, "color_table: FREED %d\n",idx);*/
}