Skip to content

Commit

Permalink
ns-do-applescript: protect source code string from garbage collection
Browse files Browse the repository at this point in the history
As an attempt to fix the crash in ns_do_applescript (TTermEntry::NextSubTerm).
The reasoning here is that the NSString used to construct the AppleScript object
is sufficiently protected from Cocoa's/ObjC GC.  So, perhaps the NS run loop called up
in ns-do-applescript causes Emacs/Lisp to be executed via some callbacks, and its GC.
(This may be a bug in itself.)
  • Loading branch information
davidswelt committed Jan 13, 2012
1 parent 0dd9193 commit a7252e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nsfns.m
Expand Up @@ -2673,6 +2673,8 @@ and GNUstep implementations ("distributor-specific release
(script)
Lisp_Object script;
{
struct gcpro gcpro1;

Lisp_Object result;
long status;
NSEvent *nxev;
Expand All @@ -2681,6 +2683,7 @@ and GNUstep implementations ("distributor-specific release
check_ns ();

BLOCK_INPUT;
GCPRO1 (script);

as_script = script;
as_result = &result;
Expand All @@ -2706,7 +2709,10 @@ and GNUstep implementations ("distributor-specific release
as_status = 0;
as_script = Qnil;
as_result = 0;

UNGCPRO;
UNBLOCK_INPUT;

if (status == 0)
return result;
else if (!STRINGP (result))
Expand Down

0 comments on commit a7252e4

Please sign in to comment.