On Nov 1, 2011, at 6:31 PM, Jens Alfke wrote:
> On Nov 1, 2011, at 3:06 PM, Vojtěch Meluzín wrote:
>
>> Anyway we are getting out of the topic. Does anyone here know why the modal
>> windows work in a plugin (in a normal application) and not from a console
>> application?
>
> Basically, apps aren’t intended to be launched by a plain exec. A normal
> launch through the LaunchServices API provides some extra setup and state.
> You _can_ launch an app from a shell or equivalent, and it’ll mostly work,
> but that’s mostly as a convenience for developers and for debugging, and
> there’s no guarantee that everything will work correctly. One of the known
> side effects is that the app launches in an indeterminate state in between
> active and inactive, which is probably what you’re seeing.
>
> If you need to launch an app programmatically, look at the LaunchServices
> API, or from a shell use the ‘open’ command on the bundle.
This is inaccurate. The issue is not related to how it was launched.
Everything boils down to execv().
The problem is whether the app is bundled with an Info.plist or, if a flat
file, has an Info.plist embedded in a segment. The frameworks use that info to
establish the connection to the window server and incorporate the app into the
GUI (having a Dock icon, etc.).
A properly bundled app will behave roughly the same whether launched via Launch
Services or directly via execv(). ("Roughly" means there may be differences
due to inherited environment variables, where stdout and stderr go, which Apple
events it receives initially, whether multiple instances are launched vs.
activating an already-running instance, and stuff like that.)
If you need to present a GUI from a process which began life as a console app,
look into -[NSApplication setActivationPolicy:] or, prior to 10.6, the
TransformProcessType() function. You'll need to invoke [NSApplication
sharedApplication] either way. Read the class overview of NSApplication for
further information.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]