Bug 563712 - [WIN32] Also call update (); in Display#runDeferredLayouts similar to GTK
Summary: [WIN32] Also call update (); in Display#runDeferredLayouts similar to GTK
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.16   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.18   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 558392
  Show dependency tree
 
Reported: 2020-05-29 07:05 EDT by Lars Vogel CLA
Modified: 2020-09-02 05:28 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2020-05-29 07:05:32 EDT
GTK: 
boolean runDeferredLayouts () {
	if (layoutDeferredCount != 0) {
		Composite[] temp = layoutDeferred;
		int count = layoutDeferredCount;
		layoutDeferred = null;
		layoutDeferredCount = 0;
		for (int i = 0; i < count; i++) {
			Composite comp = temp[i];
			if (!comp.isDisposed()) comp.setLayoutDeferred (false);
		}
		update ();
		return true;
	}
	return false;
}

Win32:
boolean runDeferredLayouts () {
	if (layoutDeferredCount != 0) {
		Composite[] temp = layoutDeferred;
		int count = layoutDeferredCount;
		layoutDeferred = null;
		layoutDeferredCount = 0;
		for (int i = 0; i < count; i++) {
			Composite comp = temp[i];
			if (!comp.isDisposed()) comp.setLayoutDeferred (false);
		}
		return true;
	}
	return false;
}

As Paul discovered the update call is missing in win32.
Comment 1 Eclipse Genie CLA 2020-05-29 07:06:30 EDT
New Gerrit change created: https://git.eclipse.org/r/163837
Comment 2 Niraj Modi CLA 2020-06-09 05:09:11 EDT
I don't see an update() call on MAC as well:
boolean runDeferredLayouts () {
	if (layoutDeferredCount != 0) {
		Composite[] temp = layoutDeferred;
		int count = layoutDeferredCount;
		layoutDeferred = null;
		layoutDeferredCount = 0;
		for (int i = 0; i < count; i++) {
			Composite comp = temp[i];
			if (!comp.isDisposed()) comp.setLayoutDeferred (false);
		}
		return true;
	}
	return false;
}

Quick queries:
1. Do we know a breaking use-case which works on GTK and not on Win32(or may be MAC as well) ?
2. To be consistent we should update MAC code as well.
Comment 3 Lars Vogel CLA 2020-06-09 05:36:09 EDT
(In reply to Niraj Modi from comment #2)

> 1. Do we know a breaking use-case which works on GTK and not on Win32(or may
> be MAC as well) ?

For example, we have extra code here for windows.

https://git.eclipse.org/r/#/c/163834/3/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java

A requestLayout without update() does not update the UI under windows in this case.
Comment 4 Lars Vogel CLA 2020-06-12 03:08:56 EDT
(In reply to Lars Vogel from comment #3)
> (In reply to Niraj Modi from comment #2)
> 
> > 1. Do we know a breaking use-case which works on GTK and not on Win32(or may
> > be MAC as well) ?
> 
> For example, we have extra code here for windows.
> 
> https://git.eclipse.org/r/#/c/163834/3/bundles/org.eclipse.e4.ui.workbench.
> renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java
> 
> A requestLayout without update() does not update the UI under windows in
> this case.

Niraj, could you check this example?
Comment 5 Niraj Modi CLA 2020-06-16 13:01:13 EDT
(In reply to Lars Vogel from comment #3)
> (In reply to Niraj Modi from comment #2)
> 
> > 1. Do we know a breaking use-case which works on GTK and not on Win32(or may
> > be MAC as well) ?
Ok, for MAC I see bug 564073

> For example, we have extra code here for windows.
> 
> https://git.eclipse.org/r/#/c/163834/3/bundles/org.eclipse.e4.ui.workbench.
> renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java
> 
> A requestLayout without update() does not update the UI under windows in
> this case.

Searched for possible calls to display.runDeferredLayouts () and update() method combination in SWT.
SWT's Tracker.open() method looks interesting, where I can see some event processing between display.runDeferredLayouts () @line 586 and update() line 608.

So, clubbing display.update() with display.runDeferredLayouts() may have some unknown side-effects.

Also with this change there exists a possibility of SWT client code calling update() twice(specifically for SWT client who are used to calling update() separately).
Comment 6 Lars Vogel CLA 2020-06-17 10:46:51 EDT
(In reply to Niraj Modi from comment #5)
> Searched for possible calls to display.runDeferredLayouts () and update()
> method combination in SWT.
> SWT's Tracker.open() method looks interesting, where I can see some event
> processing between display.runDeferredLayouts () @line 586 and update() line
> 608.
> 
> So, clubbing display.update() with display.runDeferredLayouts() may have
> some unknown side-effects.

I'm sorry but I do not understand. Currently we have to call it in platform directly, so any side-effect will be already there.
 
> Also with this change there exists a possibility of SWT client code calling
> update() twice(specifically for SWT client who are used to calling update()
> separately).

In this case the clients might be working around the issue that we do currently not call update() like we have to do in platform. So fixing this in SWT would allow them (including platform UI) to remove these workaround. And I think calling update() twice does not do harm (except the double call).
Comment 7 Niraj Modi CLA 2020-06-22 07:29:57 EDT
(In reply to Lars Vogel from comment #6)
> (In reply to Niraj Modi from comment #5)
> > Searched for possible calls to display.runDeferredLayouts () and update()
> > method combination in SWT.
> > SWT's Tracker.open() method looks interesting, where I can see some event
> > processing between display.runDeferredLayouts () @line 586 and update() line
> > 608.
> > 
> > So, clubbing display.update() with display.runDeferredLayouts() may have
> > some unknown side-effects.
> 
> I'm sorry but I do not understand. Currently we have to call it in platform
> directly, so any side-effect will be already there.
To summarize on above:
Unlike platform example(comment 3) in SWT's Windows Tracker.open() method:
- display.update() method call is very much conditional
- Also there's some event processing as well in between display.runDeferredLayouts () and display.update() method calls.

We have contrasting examples here, which suggests not mandate to call update (); in Display#runDeferredLayouts on SWT Windows.
Comment 8 Lakshmi P Shanmugam CLA 2020-07-10 03:11:20 EDT
Resetting target, please re-target as required.
Comment 9 Niraj Modi CLA 2020-09-02 04:53:21 EDT
Mass move out to 4.18
Comment 10 Lars Vogel CLA 2020-09-02 05:28:32 EDT
Looks like this change is not necessary.