Shoudl LiveCode be calling exit() when terminating a Cocoa app?

Trevor DeVore lists at mangomultimedia.com
Fri Aug 28 14:00:05 EDT 2020


Hi all,

This is probably a question for someone from the LC team who works on the
engine. If anyone else is familiar with how LC quits on macOS please chime
in though.

Scenario: I am running tests with the Sparkle.framework on macOS (which I
already use) with the goal of silently and automatically downloading
updates for an application that will be installed the next time the user
quits the application. You can see similar behavior in apps such as Slack.

Sparkle support: Sparkle supports this type of behavior if you set some
properties. It checks and downloads an update to the local cache and then
installs the update when the hosting app graceful terminates.

Problem: I have confirmed that Sparkle downloads the updates to the cache
but the update is never installed when I quit. I'm wondering if this is due
to the use of exit(t_exit_code) in -applicationWillTerminate in mac-core.mm.

Additional Info: While researching the problem I found an issue in the
Sparkle Github project which had some interesting information in it. The
author of the issue mentions that the app terminates by calling exit(0):
https://github.com/sparkle-project/Sparkle/issues/1047#issuecomment-298029934

The maintainer says that Sparkle only supports graceful termination via
Cocoa notification:
https://github.com/sparkle-project/Sparkle/issues/1047#issuecomment-298041354

So I started looking through the LiveCode source code to see how LiveCode
terminates an app when `quit` is called in LiveCode Script. If found
mac-core.mm which has the main run loop which calls `[NSApp terminate:
self];` when it is time to quit:

https://github.com/livecode/livecode/blob/develop/engine/src/mac-core.mm#L360

That looks right. But farther down in applicationWillTerminate I found a
call to `exit(t_exit_code)`;

https://github.com/livecode/livecode/blob/develop/engine/src/mac-core.mm#L416

I'm wondering if that call to exit() is what is causing problems as my
understanding is that exit() immediately causes an app to terminate.
Perhaps exit() should only be called if t_exit_code > 0?

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com



More information about the use-livecode mailing list