Community
Participate
Working Groups
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();
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.