title: LSUIElement=YES + kProcessTransformToForegroundApplication: duplicated dock icons
body: <p>I noticed some weired behaviour under 10.7.3 and higher (also under 10.8).</p>
  
  <p>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 <code>LSUIElement=YES</code> in the Info.plist. If the user has configured the Dock-Icon to be displayed I am doing</p>
  
  <p><code>TransformProcessType(&amp; (ProcessSerialNumber){ 0, kCurrentProcess }, kProcessTransformToForegroundApplication);</code> </p>
  
  <p>in applicationDidFinishLaunching.</p>
  
  <p>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 <code>TransformProcessType(&amp; (ProcessSerialNumber){ 0, kCurrentProcess }, kProcessTransformToForegroundApplication);</code>  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.</p>
  
  <p>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 <code>LSUIElement=NO</code> and using <code>kProcessTransformToUIElementApplication</code>, 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.</p>