Bug 96440 - Tables laying out 3 times when trying to determine sizes
Summary: Tables laying out 3 times when trying to determine sizes
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 83193 93611
  Show dependency tree
 
Reported: 2005-05-24 11:11 EDT by Tod Creasey CLA
Modified: 2005-05-27 10:11 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2005-05-24 11:11:33 EDT
20050522

See Bug 93611

When we attempt to layout a table we are scaling columns with
table.getClientArea().width. In M6 this returned the width of the table - post
M6 it is returning a much smaller value and making all of our columns very small
in the Table Layout.

STEPS
1) Put a breakpoint in the JFace TableLayout class
2) Launch a self hosted workspace
3) Open Preferences-> Ant Runtime 
4) You will see a client area size of about 81
5) Do the same in M6 - it will be about 320 or so.
Comment 1 Tod Creasey CLA 2005-05-24 14:12:23 EDT
This is a windows only problem. On GTK and the Mac we are still getting decent
sizes.
Comment 2 Michael Valenta CLA 2005-05-24 14:34:07 EDT
Actually, there may be problems on GTK as well. It looks better because the 
last column is bigger but the other columns are quite small and probably do 
not match the weighting that was given them.
Comment 3 Tod Creasey CLA 2005-05-24 15:08:59 EDT
I have traced through the issue and it is because we are getting called to
layout the Table once on computeSize and twice on setSize. In M6 we were only
getting called during setSize and then only once.

As a result this initial layout we determine is premature as we are attempting
only an initial computation to set the size.  As we only resize on the first
call we end up with this base size.

Here are stack traces of the 3 calls

Thread [main] (Suspended (breakpoint at line 109 in TableLayout))
	TableLayout.layout(Composite, boolean) line: 109
	Table(Composite).updateLayout(boolean, boolean) line: 869
	Table.WM_WINDOWPOSCHANGED(int, int) line: 3622
	Table(Control).windowProc(int, int, int, int) line: 3116
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.WM_SIZE(int, int) line: 1252
	Composite(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]
	OS.DefWindowProc(int, int, int, int) line: 1645
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77
	Composite(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	TabFolder(Composite).resizeChildren(boolean, WINDOWPOS[]) line: 653
	TabFolder(Composite).resizeChildren() line: 619
	TabFolder(Composite).setResizeChildren(boolean) line: 786
	TabFolder(Composite).WM_SIZE(int, int) line: 1252
	TabFolder.WM_SIZE(int, int) line: 782
	TabFolder(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.CallWindowProcW(int, int, int, int, int) line: not available [native method]
	OS.CallWindowProc(int, int, int, int, int) line: 1574
	TabFolder.callWindowProc(int, int, int, int) line: 159
	TabFolder(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.updateLayout(boolean, boolean) line: 870
	Composite.layout(boolean, boolean) line: 493
	Composite.layout(boolean) line: 458
	AntRuntimePreferencePage(PreferencePage).doComputeSize() line: 339
	AntRuntimePreferencePage(PreferencePage).computeSize() line: 162
	PreferenceDialog$13.run() line: 1159
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	JFaceUtil$1.run(ISafeRunnable) line: 44
	SafeRunnable.run(ISafeRunnable) line: 148
	WorkbenchPreferenceDialog(PreferenceDialog).showPage(IPreferenceNode) line: 1153
	WorkbenchPreferenceDialog(FilteredPreferenceDialog).showPage(IPreferenceNode)
line: 351
	PreferenceDialog$8.selectionChanged(SelectionChangedEvent) line: 639
	StructuredViewer$3.run() line: 763
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	JFaceUtil$1.run(ISafeRunnable) line: 44
	SafeRunnable.run(ISafeRunnable) line: 148
	TreeViewer(StructuredViewer).firePostSelectionChanged(SelectionChangedEvent)
line: 761
	TreeViewer(StructuredViewer).handlePostSelect(SelectionEvent) line: 1042
	StructuredViewer$5.widgetSelected(SelectionEvent) line: 1062
	OpenStrategy.firePostSelectionEvent(SelectionEvent) line: 231
	OpenStrategy.access$4(OpenStrategy, SelectionEvent) line: 226
	OpenStrategy$3.run() line: 392
	RunnableLock.run() line: 35
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118
	Display.runAsyncMessages(boolean) line: 2900
	Display.readAndDispatch() line: 2559
	WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 811
	WorkbenchPreferenceDialog(Window).open() line: 789
	OpenPreferencesAction.run() line: 66
	OpenPreferencesAction(Action).runWithEvent(Event) line: 996
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 538
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 488
	ActionContributionItem$5.handleEvent(Event) line: 400
	EventTable.sendEvent(Event) line: 82
	MenuItem(Widget).sendEvent(Event) line: 844
	Display.runDeferredEvents() line: 2923
	Display.readAndDispatch() line: 2556
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1652
	Workbench.runUI() line: 1616
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 336
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
	IDEApplication.run(Object) line: 103
	PlatformActivator$1.run(Object) line: 226
	EclipseStarter.run(Object) line: 372
	EclipseStarter.run(String[], Runnable) line: 161
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available
[native method]
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
	Method.invoke(Object, Object[]) line: 324
	Main.invokeFramework(String[], URL[]) line: 330
	Main.basicRun(String[]) line: 274
	Main.run(String[]) line: 969
	Main.main(String[]) line: 944

Thread [main] (Suspended (breakpoint at line 109 in TableLayout))
	TableLayout.layout(Composite, boolean) line: 109
	Table(Composite).updateLayout(boolean, boolean) line: 869
	Table.WM_WINDOWPOSCHANGED(int, int) line: 3622
	Table(Control).windowProc(int, int, int, int) line: 3116
	Display.windowProc(int, int, int, int) line: 3535
	OS.CallWindowProcW(int, int, int, int, int) line: not available [native method]
	OS.CallWindowProc(int, int, int, int, int) line: 1574
	Table.callWindowProc(int, int, int, int, boolean) line: 196
	Table.callWindowProc(int, int, int, int) line: 141
	Table.WM_WINDOWPOSCHANGED(int, int) line: 3615
	Table(Control).windowProc(int, int, int, int) line: 3116
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.WM_SIZE(int, int) line: 1252
	Composite(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]
	OS.DefWindowProc(int, int, int, int) line: 1645
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77
	Composite(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	TabFolder(Composite).resizeChildren(boolean, WINDOWPOS[]) line: 653
	TabFolder(Composite).resizeChildren() line: 619
	TabFolder(Composite).setResizeChildren(boolean) line: 786
	TabFolder(Composite).WM_SIZE(int, int) line: 1252
	TabFolder.WM_SIZE(int, int) line: 782
	TabFolder(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.CallWindowProcW(int, int, int, int, int) line: not available [native method]
	OS.CallWindowProc(int, int, int, int, int) line: 1574
	TabFolder.callWindowProc(int, int, int, int) line: 159
	TabFolder(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.WM_SIZE(int, int) line: 1252
	Composite(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]
	OS.DefWindowProc(int, int, int, int) line: 1645
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77
	Composite(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native
method]
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1139
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 1953
	Composite(Control).setBounds(int, int, int, int, int) line: 1934
	Composite(Control).setSize(int, int) line: 2383
	Composite(Control).setSize(Point) line: 2407
	AntRuntimePreferencePage(PreferencePage).setSize(Point) line: 490
	WorkbenchPreferenceDialog(PreferenceDialog).showPage(IPreferenceNode) line: 1188
	WorkbenchPreferenceDialog(FilteredPreferenceDialog).showPage(IPreferenceNode)
line: 351
	PreferenceDialog$8.selectionChanged(SelectionChangedEvent) line: 639
	StructuredViewer$3.run() line: 763
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	JFaceUtil$1.run(ISafeRunnable) line: 44
	SafeRunnable.run(ISafeRunnable) line: 148
	TreeViewer(StructuredViewer).firePostSelectionChanged(SelectionChangedEvent)
line: 761
	TreeViewer(StructuredViewer).handlePostSelect(SelectionEvent) line: 1042
	StructuredViewer$5.widgetSelected(SelectionEvent) line: 1062
	OpenStrategy.firePostSelectionEvent(SelectionEvent) line: 231
	OpenStrategy.access$4(OpenStrategy, SelectionEvent) line: 226
	OpenStrategy$3.run() line: 392
	RunnableLock.run() line: 35
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118
	Display.runAsyncMessages(boolean) line: 2900
	Display.readAndDispatch() line: 2559
	WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 811
	WorkbenchPreferenceDialog(Window).open() line: 789
	OpenPreferencesAction.run() line: 66
	OpenPreferencesAction(Action).runWithEvent(Event) line: 996
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 538
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 488
	ActionContributionItem$5.handleEvent(Event) line: 400
	EventTable.sendEvent(Event) line: 82
	MenuItem(Widget).sendEvent(Event) line: 844
	Display.runDeferredEvents() line: 2923
	Display.readAndDispatch() line: 2556
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1652
	Workbench.runUI() line: 1616
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 336
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
	IDEApplication.run(Object) line: 103
	PlatformActivator$1.run(Object) line: 226
	EclipseStarter.run(Object) line: 372
	EclipseStarter.run(String[], Runnable) line: 161
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available
[native method]
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
	Method.invoke(Object, Object[]) line: 324
	Main.invokeFramework(String[], URL[]) line: 330
	Main.basicRun(String[]) line: 274
	Main.run(String[]) line: 969
	Main.main(String[]) line: 944

Thread [main] (Suspended (breakpoint at line 109 in TableLayout))
	TableLayout.layout(Composite, boolean) line: 109
	Table(Composite).updateLayout(boolean, boolean) line: 869
	Table.WM_WINDOWPOSCHANGED(int, int) line: 3622
	Table(Control).windowProc(int, int, int, int) line: 3116
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.WM_SIZE(int, int) line: 1252
	Composite(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]
	OS.DefWindowProc(int, int, int, int) line: 1645
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77
	Composite(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	TabFolder(Composite).resizeChildren(boolean, WINDOWPOS[]) line: 653
	TabFolder(Composite).resizeChildren() line: 619
	TabFolder(Composite).setResizeChildren(boolean) line: 786
	TabFolder(Composite).WM_SIZE(int, int) line: 1252
	TabFolder.WM_SIZE(int, int) line: 782
	TabFolder(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.CallWindowProcW(int, int, int, int, int) line: not available [native method]
	OS.CallWindowProc(int, int, int, int, int) line: 1574
	TabFolder.callWindowProc(int, int, int, int) line: 159
	TabFolder(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.EndDeferWindowPos(int) line: not available [native method]
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 653
	Composite.resizeChildren() line: 619
	Composite.setResizeChildren(boolean) line: 786
	Composite.WM_SIZE(int, int) line: 1252
	Composite(Control).windowProc(int, int, int, int) line: 3107
	Display.windowProc(int, int, int, int) line: 3535
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]
	OS.DefWindowProc(int, int, int, int) line: 1645
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77
	Composite(Control).windowProc(int, int, int, int) line: 3123
	Display.windowProc(int, int, int, int) line: 3535
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native
method]
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1139
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 1953
	Composite(Control).setBounds(int, int, int, int, int) line: 1934
	Composite(Control).setSize(int, int) line: 2383
	Composite(Control).setSize(Point) line: 2407
	AntRuntimePreferencePage(PreferencePage).setSize(Point) line: 490
	WorkbenchPreferenceDialog(PreferenceDialog).showPage(IPreferenceNode) line: 1188
	WorkbenchPreferenceDialog(FilteredPreferenceDialog).showPage(IPreferenceNode)
line: 351
	PreferenceDialog$8.selectionChanged(SelectionChangedEvent) line: 639
	StructuredViewer$3.run() line: 763
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	JFaceUtil$1.run(ISafeRunnable) line: 44
	SafeRunnable.run(ISafeRunnable) line: 148
	TreeViewer(StructuredViewer).firePostSelectionChanged(SelectionChangedEvent)
line: 761
	TreeViewer(StructuredViewer).handlePostSelect(SelectionEvent) line: 1042
	StructuredViewer$5.widgetSelected(SelectionEvent) line: 1062
	OpenStrategy.firePostSelectionEvent(SelectionEvent) line: 231
	OpenStrategy.access$4(OpenStrategy, SelectionEvent) line: 226
	OpenStrategy$3.run() line: 392
	RunnableLock.run() line: 35
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118
	Display.runAsyncMessages(boolean) line: 2900
	Display.readAndDispatch() line: 2559
	WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 811
	WorkbenchPreferenceDialog(Window).open() line: 789
	OpenPreferencesAction.run() line: 66
	OpenPreferencesAction(Action).runWithEvent(Event) line: 996
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 538
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 488
	ActionContributionItem$5.handleEvent(Event) line: 400
	EventTable.sendEvent(Event) line: 82
	MenuItem(Widget).sendEvent(Event) line: 844
	Display.runDeferredEvents() line: 2923
	Display.readAndDispatch() line: 2556
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1652
	Workbench.runUI() line: 1616
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 336
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
	IDEApplication.run(Object) line: 103
	PlatformActivator$1.run(Object) line: 226
	EclipseStarter.run(Object) line: 372
	EclipseStarter.run(String[], Runnable) line: 161
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available
[native method]
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
	Method.invoke(Object, Object[]) line: 324
	Main.invokeFramework(String[], URL[]) line: 330
	Main.basicRun(String[]) line: 274
	Main.run(String[]) line: 969
	Main.main(String[]) line: 944

Comment 4 Veronika Irvine CLA 2005-05-24 16:35:40 EDT
According to your traces, Preference Page is forcing a layout in the call to 
computeSize:

    Composite.layout(boolean) line: 458
    AntRuntimePreferencePage(PreferencePage).doComputeSize() line: 339

Also, PreferencePage is calling setSize from showPage and showPage is being 
called twice.

The preference dialog is running an event loop and some asynchronous messages 
are being processed.  

Did you recently change the way OpenStrategy works?  Steve says there may be 
some recent changes to the way selection in a Tree/Table behaves - is the 
OpenStrategy hooked to selection in the Tree?
Comment 5 Tod Creasey CLA 2005-05-24 17:02:05 EDT
I think that may be the case. The time we call layout on the parent is if we are
asked to computeSize when the control is null.

We do this in the following case: the page has not been created and the optional
descriptionLabel has been used. 

This is happening as a result of a post selection changed callback from
OpenStrategy that occurs after the selection is made. The OpenStrategy is tied
to the tree selection - it is the tree selection that generates this.
Comment 6 Tod Creasey CLA 2005-05-24 17:03:26 EDT
Looking at 0522 on Linux the first columns are crunched - only the last one is
the correct size.

Except for copyright updates OpenStraegy has not changed since 20040618
Comment 7 Steve Northover CLA 2005-05-24 21:53:38 EDT
SN and VI to investigate.  VI, can you confirm that we are not sending extra 
layout/resizes?
Comment 8 Nick Edgar CLA 2005-05-25 09:41:56 EDT
Seems strange that OpenStrategy is used here, since single-click should always
show the selected preference page, regardless of the open mode.
Comment 9 Tod Creasey CLA 2005-05-25 10:39:45 EDT
OK so more results from digging. The difference seems to be in changes in
GridLayout not selection - we are getting the same selections as always.

line 670 has the following code:

if (child != null) {
	child.setBounds (childX, childY, childWidth, childHeight);
					}

This is what generates the early layout call. In M6 we did not hit it.
Comment 10 Tod Creasey CLA 2005-05-25 11:04:38 EDT
The AntPreferencePage switched from using a composite as the top element in the
page to using a TabFolder with a custom layout.

If you change createContents of AntPreferencePage to read

Composite outer = new Composite(parent,SWT.NONE);
		outer.setLayout(new GridLayout());
		outer.setLayoutData(new GridData(GridData.FILL_BOTH));

		TabFolder folder = new TabFolder(outer, SWT.NONE);
		folder.setLayout(new TabFolderLayout());	
		folder.setLayoutData(new GridData(GridData.FILL_BOTH));
		folder.setFont(parent.getFont());

The columns layout fine
Comment 11 Darin Swanson CLA 2005-05-25 11:21:30 EDT
Thanks...but changing the AntRuntimePreferencePage.createContents does not 
seem to fix the problem on my WinXP box. And I am unaware of when 
we "switched" our code since at least Aug 2003?
Comment 12 Tod Creasey CLA 2005-05-25 11:46:29 EDT
I tried loading JFace from HEAD and SWT and Ant from M6 and the problem still
exists apparently because the reduced number of Composites we have causes us to
hit code in different places.

In the end it is a problem with our long standing layout call on computeSize in
a preference page which is just a bad way to code size computation. Nick and I
talked it over and if it is OK after testing and with Layout Queen Veronika I
would just as soon remove the bad code from JFace and have SWT make no changes.
Comment 13 Tod Creasey CLA 2005-05-25 13:10:26 EDT
This really all comes down to the unneccessary layout we are doing on
computeSize. I have checked with Nick nd Veronika and they both concur that this
line can be removed.

I have checked all of our existing pages on Windows and GTK and this fix seems fine.

I'll take this one for us.
Comment 14 Tod Creasey CLA 2005-05-25 13:57:41 EDT
Fixed in build >20050525
Comment 15 Tod Creasey CLA 2005-05-27 10:11:33 EDT
Verified in 20050526