At 3:11 PM -0800 3/5/99, Christopher Hunt wrote:
>> The problem is that sub-launching another app isn't generally supported by
>> the OS, and will cause lots of subsequent problems. Only the prefs panels
>> are really set up to be smart enough to handle a sub-launch.
>
>What do you mean generally non-supported? Why is it documented as supported
>then? What do the prefs panels actually do to become "smart"? Your comment
>disturbs me given that a lot of apps may be using SysAppLaunch. :-(
Uh oh, the worms are squirming out. I knew I should have kept my mouth shut...
Anyway, SysAppLaunch should really only be used in a few carefully
controlled ways. It provides a lot more API than is really necessary for
apps, and unfortunately the documentation isn't as clear as it could be.
What makes you think a lot of apps are using SysAppLaunch?? That doesn't
seem like the case to me, apps that use that functions should be very rare.
The prefs panels look at the launch code, and if they're called from some
other app, they hide their panel-switching UI and show a DONE button. The
DONE button works by enqueuing a stop event, which causes the panel to
exit and control returns to the calling app.
Since most 3rd party apps don't have any kind of 'DONE' UI, there's no way
to induce them to simply quit, so there's no good way to have control
return to your super-launching app.
If you want to write a launcher replacement, you should do what our
launcher does -- use SysUIAppSwitch, which sets a global indicating app you
want to launch next, then enqueus a stop event to tell the launcher to
quit. Control returns to the UI thread top-level, which looks at the
global and launches that app.
In this way, we ensure that only one app is normally running at a time,
which is good because it allows the maximum amount of system resources
(heap, stack, etc) to be given to the running app.
If you attempt to sub-launch some other app which doesn't support this,
that app could fail for lack of memory because your app is keeping some
space for itself.
...there are also messy details about whose globals are available, but I'm
not as "up" on those issues so I can't tell you much about them.
--Bob