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

Bug 351994

Summary: Deferred layouts can cause controls to not get a layout data set on them
Product: [Eclipse Project] Platform Reporter: Remy Suen <remy.suen>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: pwebster, sxenos
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Remy Suen CLA 2011-07-13 11:40:32 EDT
Are clients supposed to be able to expect that their controls will have layout data automatically generated and set for them when their parent composite has been laid out?

In the case where the parent's composite's layout has been asked to be deferred, this automatic layout data generation will not happen and was the cause behind bug 345354.

Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());
Composite c = new Composite(shell, SWT.NONE);
shell.setLayoutDeferred(true);
shell.layout(true, true);
System.out.println(c.getLayoutData());
shell.dispose();
display.dispose();
Comment 1 Stefan Xenos CLA 2016-05-24 09:25:33 EDT
I can't find anything in the JavaDoc which promises that invocations of layout will attach layout data to the child widgets. I would also recommend against making such a promise in the future since doing so would complicate the already-complicated layout system even more. Also, third-party layouts which currently don't attach data to their children would break such a promise.

It is very easy for clients to invoke setLayoutData themselves if they want getLayoutData() to be non-null.