I noticed some weired behaviour under 10.7.3 and higher (also under 10.8).
My app is a little helper app that has an NSStatusItem and a dock icon by default. The user can configure, if he wants to display only the StatusItem, the Dock icon or both.
To reailze this I am having LSUIElement=YES
in the Info.plist. If the user has configured the Dock-Icon to be displayed I am doing
TransformProcessType(& (ProcessSerialNumber){ 0, kCurrentProcess }, kProcessTransformToForegroundApplication);
in applicationDidFinishLaunching.
This worked fine until 10.7.3. Starting with 10.7.3 the dock icon is sometimes displayed two times (though only one instance of the app is running). In this case the app can be terminated normally, but the second icon remains unresponsive in the dock. Restarting the dock makes the icon dissappear. This mainly happens, if the app is an LoginItem and automatically started on login.
Executing TransformProcessType(& (ProcessSerialNumber){ 0, kCurrentProcess }, kProcessTransformToForegroundApplication);
with a delay of 1 second or more seems to solve the issue. It's however not a good approach as the user gets no instant feedback, that the application has been started.
Does anyone know anything about this issue and a possible workaround/solution? Some googling revealed that Growl seems to have this issue starting in 10.7.3 as well, but not any solution.
Note: Setting LSUIElement=NO
and using kProcessTransformToUIElementApplication
, if the user has chosen not to display the dock-icon does not work for me as the app needs to be compatible with 10.5 and 10.6.