Bug 545220 - [GTK] Random themes get loaded in Display.initializeSystemColors()
Summary: [GTK] Random themes get loaded in Display.initializeSystemColors()
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.11   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.12 M1   Edit
Assignee: Alexandr Miloslavskiy CLA
QA Contact: Eric Williams CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-03-08 11:09 EST by Alexandr Miloslavskiy CLA
Modified: 2019-04-09 10:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr Miloslavskiy CLA 2019-03-08 11:09:18 EST
This happens because 'OS.getThemeNameBytes' returns non-zero-terminated string. When this string gets passed to 'gtk_css_provider_get_named', it can load correct or wrong theme, depending on how starts align.

This even causes very interesting behavior where putting a breakpoint on 'gtk_css_provider_get_named' causes another theme to be loaded.

Will submit fix soon...
Comment 1 Eric Williams CLA 2019-03-08 11:17:41 EST
Interesting. I'm always happy to review patches, so just add me as a reviewer and I'll take a look. :)
Comment 2 Eclipse Genie CLA 2019-03-08 11:35:04 EST
New Gerrit change created: https://git.eclipse.org/r/138400
Comment 3 Alexandr Miloslavskiy CLA 2019-03-08 11:37:37 EST
For me, the easiest way to reproduce was to add this code in 'Display.initializeSystemColors':
------------------------
long /*int*/ themeProvider = GTK.gtk_css_provider_get_named(buffer, darkBuffer);
System.out.format("themeProvider0000 = %X%n", themeProvider);

long /*int*/ lastThemeProvider = themeProvider;
for (int i = 1; i < 10*1024; i++) {
	long /*int*/ themeProviderN = GTK.gtk_css_provider_get_named(buffer, darkBuffer);

	if (lastThemeProvider != themeProviderN) {
		lastThemeProvider = themeProviderN;
		System.out.format("themeProvider%04d = %X <--- new%n", i, themeProviderN);
	} else {
		System.out.format("themeProvider%04d = %X%n", i, themeProviderN);
	}
}
------------------------

It also happened to me when I set breakpoint on 'gtk_css_provider_get_named.
Comment 5 Eric Williams CLA 2019-03-11 14:17:45 EDT
(In reply to Eclipse Genie from comment #4)
> Gerrit change https://git.eclipse.org/r/138400 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=2ba1851a26f7feee69700dea35584a0b505c78d6

In master now.
Comment 6 Eric Williams CLA 2019-04-09 10:10:34 EDT
Verified in I20190409-0600.