Bug 4805 - resize during setRedraw causes cheese (1GJ4URX)
Summary: resize during setRedraw causes cheese (1GJ4URX)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Windows All
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 12356 15014 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-11 14:23 EDT by Veronika Irvine CLA
Modified: 2005-06-14 12:58 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 Veronika Irvine CLA 2001-10-11 14:23:18 EDT
When you setRedraw(false) on a widget and then resize the widget and then setRedraw(true), the area that is re-painted after the
setRedraw(true) is just the area of the new size of the widget.  This is OK if the widget was made larger but this causes cheese if 
the widget has been made smaller or moved.  See the example below to demonstrate this.

Note: Fixing this problem may not entirely solve the above problem.

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	final Color red = display.getSystemColor(SWT.COLOR_RED);
	final Color blue = display.getSystemColor(SWT.COLOR_BLUE);
	final Canvas canvas = new Canvas(shell, SWT.NONE);
	canvas .setBounds(10, 70, 100, 100);
	canvas.setBackground(red);
	Button b = new Button(shell, SWT.PUSH);
	b.setText("change");
	b.setBounds(10, 10, 100, 40);
	b.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			canvas.setRedraw(false);
			Point size = canvas.getSize();
			if (size.x == 100) {
				canvas.setSize(300, 300);
				canvas.setBackground(blue);
			} else {
				canvas.setSize(100, 100);
				canvas.setBackground(red);
			}
			canvas.setRedraw(true);
		}
	});
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}

NOTES:

VI (27/08/2001 3:53:10 PM)
setRedraw should damage call RedrawWindow on the parent and should damage both the old client rect and the new client rect.

SN (8/29/01 11:08:06 AM)
	That sounds like a scary fix.
Comment 1 DJ Houghton CLA 2001-10-29 16:39:54 EST
PRODUCT VERSION:
1.0 132

Comment 2 Mike Wilson CLA 2001-12-10 14:38:42 EST
Document that you should never resize during setRedraw(false).
Comment 3 Steve Northover CLA 2002-05-14 10:32:18 EDT
*** Bug 15014 has been marked as a duplicate of this bug. ***
Comment 4 Randy Hudson CLA 2003-11-14 17:20:56 EST
*** Bug 12356 has been marked as a duplicate of this bug. ***
Comment 5 Steve Northover CLA 2003-11-14 18:18:27 EST
Veronika, this was the problem that I was asking you about to see whether this 
was the cheese Randy was seeing.
Comment 6 Randy Hudson CLA 2003-11-16 16:35:59 EST
Steve, we haven't seen any recent problems in draw2d/GEF because of this issue. 
This affected us back when we first added CellEditors to GEF.  We resize the 
cell editor as you type.  Our workaround was to use the technique in one of 
your snippets to grow the Text control before the OS inserts the new characters.

Sorry for the confusion, just wanted to get CC'ed to this.
Comment 7 Matt Lavin CLA 2005-02-22 13:50:56 EST
What is the plan for this bug?  It seems like this behavior is a Windows
specific bug/feature and that Veronika's workaround could fix the problem.  McQ
suggested that it just be doc'd to say that you shouldn't resize the widget
while setRedraw(false), but it doesn't look like the doc has been updated.  

It seems reasonable to resize a widget after a setResize(false) for the same
reason you would use setRedraw(false) to hide repaints while modifing the child
widgets.  You could argue that you should call parent.setRedraw(false) before
sizing the widget, but that doesn't work when you are resizing a toplevel window.
Comment 8 Steve Northover CLA 2005-02-23 09:05:37 EST
We could have another go at this.  We were afraid to make the changes at the 
time because they were too scary.  Are you seeing this now?
Comment 9 Matt Lavin CLA 2005-02-23 09:16:57 EST
I've checked this out on GTK and it is not a problem there (at least not with 
the top-level shell resizing).  I'm mostly interesting in hearing that this is 
only a Windows bug and that the setRedraw() method will NOT be updated to 
include the statement suggested in comment 2.  

Since I'm planning on trying to fixing this for the eSWT code base I don't mind 
also submitting a patch if I can figure it out.
Comment 10 Steve Northover CLA 2005-02-23 09:49:54 EST
It's Windows only.  We were hoping to make Veronika's hack fix good someday 
but there were a bunch of issues with it that I no longer remember.
Comment 11 Steve Northover CLA 2005-06-13 11:18:16 EDT
A fix for this problem is necessary as part of the fix for bug 99266.
Comment 12 Michael Van Meekeren CLA 2005-06-14 12:10:54 EDT
talked with SN and I agree with fixing this for RC3
Comment 13 Steve Northover CLA 2005-06-14 12:58:28 EDT
Fixed > 20050614