1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-05 11:21:04 -08:00

Get rid of autorelease warnings during building on GNUstep

* src/emacs.c (decode_env_path):
* src/nsfns.m (ns_appkit_version_str):
* src/nsterm.m (ns_term_shutdown): Setup autorelease when
objects might be autoreleased during building.
This commit is contained in:
Po Lu 2022-04-25 13:42:44 +08:00
parent 45372fb1f4
commit c6809e97e4
3 changed files with 25 additions and 8 deletions

View file

@ -3153,6 +3153,9 @@ decode_env_path (const char *evarname, const char *defalt, bool empty)
{
const char *path, *p;
Lisp_Object lpath, element, tem;
#ifdef NS_SELF_CONTAINED
void *autorelease = NULL;
#endif
/* Default is to use "." for empty path elements.
But if argument EMPTY is true, use nil instead. */
Lisp_Object empty_element = empty ? Qnil : build_string (".");
@ -3180,6 +3183,8 @@ decode_env_path (const char *evarname, const char *defalt, bool empty)
if (!path)
{
#ifdef NS_SELF_CONTAINED
/* ns_relocate needs a valid autorelease pool around it. */
autorelease = ns_alloc_autorelease_pool ();
path = ns_relocate (defalt);
#else
path = defalt;
@ -3282,6 +3287,11 @@ decode_env_path (const char *evarname, const char *defalt, bool empty)
else
break;
}
#ifdef NS_SELF_CONTAINED
if (autorelease)
ns_release_autorelease_pool (autorelease);
#endif
return Fnreverse (lpath);
}

View file

@ -891,7 +891,10 @@ static Lisp_Object
ns_appkit_version_str (void)
{
NSString *tmp;
Lisp_Object string;
NSAutoreleasePool *autorelease;
autorelease = [[NSAutoreleasePool alloc] init];
#ifdef NS_IMPL_GNUSTEP
tmp = [NSString stringWithFormat:@"gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION)];
#elif defined (NS_IMPL_COCOA)
@ -901,7 +904,10 @@ ns_appkit_version_str (void)
#else
tmp = [NSString initWithUTF8String:@"ns-unknown"];
#endif
return [tmp lispString];
string = [tmp lispString];
[autorelease release];
return string;
}

View file

@ -5404,20 +5404,21 @@ ns_term_init (Lisp_Object display_name)
void
ns_term_shutdown (int sig)
{
NSAutoreleasePool *pool;
/* We also need an autorelease pool here, since this can be called
during dumping. */
pool = [[NSAutoreleasePool alloc] init];
[[NSUserDefaults standardUserDefaults] synchronize];
[pool release];
/* code not reached in emacs.c after this is called by shut_down_emacs: */
if (STRINGP (Vauto_save_list_file_name))
unlink (SSDATA (Vauto_save_list_file_name));
if (sig == 0 || sig == SIGTERM)
{
[NSApp terminate: NSApp];
}
else // force a stack trace to happen
{
emacs_abort ();
}
[NSApp terminate: NSApp];
else /* Force a stack trace to happen. */
emacs_abort ();
}