Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336503

Summary: AppID being changed unexpectedly
Product: [Eclipse Project] Platform Reporter: Matthew Hatem <Matthew_Hatem>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, gheorghe, grant_gayed, jdmiles, mpcarl, Silenio_Quarti
Version: 3.6   
Target Milestone: 3.8   
Hardware: PC   
OS: All   
Whiteboard:

Description Matthew Hatem CLA 2011-02-07 08:41:07 EST
Build Identifier: 3.6

With eclipse 3.6 they have started setting the appid in the Display init function. Bug 293229
+++ Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java	22 Feb 2010 23:52:26 -0000
@@ -110,6 +110,7 @@
 	public MSG msg = new MSG ();
 	
 	static String APP_NAME;
+	static String APP_ID;
 	
 	/* Windows and Events */
 	Event [] eventQueue;
@@ -2599,7 +2600,9 @@
 */
 protected void init () {
 	super.init ();
-		
+	
+	setAppID(APP_NAME);
+	
 	/* Create the callbacks */
 	windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$
 	windowProc = windowCallback.getAddress ();
@@ -2723,6 +2726,11 @@
 	lastHighContrast = getHighContrast ();
 }
 
+void setAppID(String appId) {
+	APP_ID = appId;
+	OS.SetCurrentProcessExplicitAppUserModelID(appId.toCharArray());
+}

This overrides the value set in the launcher.  This change has caused a regression with how we handle product branding settings such as icons.  

We recommend the init function first check if appid has been set and if so to not change it.

Reproducible: Always
Comment 1 Felipe Heidrich CLA 2011-02-07 10:03:16 EST
Does the launcher call SetCurrentProcessExplicitAppUserModelID() ? Why ?

What happens when the app calls Display#setAppName() ? is SWT suppose to ignore it (in this case where the launcher set app id)?
Comment 2 James D. Miles CLA 2011-02-16 15:51:24 EST
Yes we are calling setCurrentProcessExplicitAppUserModelID in our native code. The only problem is the initial init(). If the appID has been set it should not be overridden. If later a window wants to change we can assume it knows the efffect of such and it should be allowed.

We need to be assured that the appID is set for all events happening with the launch not just once swt is up. Per MSDN "This method must be called during an application's initial startup routine before the application presents any UI or makes any manipulation of its Jump Lists." We have other native programs also chained to the launch that sometimes present GUI so we do this during the launch of the processes.

Any method that will allow us to keep our ID is likely satisfactory but please work that out with Matt if there is a problem.
Comment 3 Felipe Heidrich CLA 2011-02-16 16:30:29 EST
Can you use Display#setAppName() to let SWT set the appID for you ?
After the display is initialized you can set up your jump list, yes ?


What if you set Display#setAppName() with the same appID you called SetCurrentProcessExplicitAppUserModelID(), will that work ?
Comment 4 Felipe Heidrich CLA 2011-02-16 16:31:16 EST
> After the display is initialized you can set up your jump list, yes ?

Note: you can use Taskbar to set a jump list in windows (with tasks).
Comment 5 James D. Miles CLA 2011-03-09 16:44:12 EST
The problem is not with taskbar it is with wrong appID.
Comment 6 Silenio Quarti CLA 2012-04-11 17:08:28 EDT
Fixed 

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2c4873016229203477f7e44fc832b4690b65c9ec

SWT only sets the ID if it has not been set yet.