Bug 17760 - ScrollBar malfunction on the draw2d ScrollPane figure
Summary: ScrollBar malfunction on the draw2d ScrollPane figure
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Randy Hudson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-24 13:34 EDT by Ondrej Chylik CLA
Modified: 2002-06-20 19:06 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Chylik CLA 2002-05-24 13:34:33 EDT
Steps to reproduce the bug:

* Run the class provided at the end of this report (any application (workbench 
or standalone) that uses the draw2d ScrollPane figure would do)

* "Tickle" one of the ScrollBars a little - try clicking an holding the mouse 
button in the area between one of the arrows and the dragable bar, so that the 
view scrolls to its bound, then use the same technique to scroll to the other 
bound. Repeat.

* After a while (rarely longer that, say, 20 seconds of "tickling") the scroll 
bar "sticks" to one of the boundaries and keeps scrolling that way whatever you 
do...

Furthermore:

* Now when you resize the window so that the viewport is large enough to 
contain its whole contents and the scrollbar(s) disappear, an exception is 
raised (the contents of stderr follows):

    org.eclipse.swt.SWTException: Failed to execute runnable 
(java.lang.NullPointerException)
        at org.eclipse.swt.SWT.error(SWT.java:1887)
        at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:148)
        at org.eclipse.swt.widgets.Display.syncExec(Display.java:1640)
        at com.ibm.etools.draw2d.ButtonModel$1.run(ButtonModel.java:396)
        at com.ibm.etools.draw2d.util.Timer.preformRun(Timer.java:38)
        at com.ibm.etools.draw2d.util.Timer.run(Timer.java:54)
        at java.lang.Thread.run(Thread.java:484)
    org.eclipse.swt.SWTException: Failed to execute runnable 
(java.lang.NullPointerException)
        at org.eclipse.swt.SWT.error(SWT.java:1887)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java:96)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1389)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1211)
        at Bug.main(Bug.java:47)
    *** Stack trace of contained exception ***
    java.lang.NullPointerException
        at com.ibm.etools.draw2d.ButtonModel$2.run(ButtonModel.java:399)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java:93)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1389)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1211)
        at Bug.main(Bug.java:47)

* If you make the window smaller again, the scrollbars will reappear and will 
work corretly (however, you may reproduce the bug over and over again)


I succeeded to reproduce the bug everytime I intended to (even several times I 
didn't mean to do so, of course).
The bug doesn't seem to occur on the SWT ScrolledComposite control.

I use the version of GEF currently downloadable from 
http://download.eclipse.org/tools/gef/gef.zip

_____


A minimal ScrollPane example:

    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    import com.ibm.etools.draw2d.LightweightSystem;
    import com.ibm.etools.draw2d.RectangleFigure;
    import com.ibm.etools.draw2d.ScrollPane;
    
    public class Bug {
    
        public static void main(String[] args) {
            Shell shell = new Shell();
            
            LightweightSystem lws = new LightweightSystem(shell);
            
            RectangleFigure rectangle = new RectangleFigure();
            rectangle.setPreferredSize(400, 300);
            
            ScrollPane scrollPane = new ScrollPane();
            scrollPane.setView(rectangle);
            
            lws.setContents(scrollPane);
            
            shell.setText("ScrollPane problem");
            shell.pack();
            shell.open();
            
            Display display = Display.getDefault();
            while (!shell.isDisposed()) {
                try {
                    if (!display.readAndDispatch()) {
                        display.sleep();
                    }
                } catch (RuntimeException re) {
                    re.printStackTrace();
                }
            }
        }
    }
Comment 1 Randy Hudson CLA 2002-05-26 23:14:11 EDT
Thanks for the report.  I believe this is already fixed in the "current" code.  
We will soon be making our current code available.

The problem had to do with the pressed and armed properties changing state, 
and "resume" being called on the firing behavior unnecessarily, which spawned 
an extra Timer thread.

Eventually we should change this to be "threadless" and use the timer function 
added to Display post V1 SWT.
Comment 2 Randy Hudson CLA 2002-06-19 15:31:16 EDT
Can you reproduce this using the latest download for GEF, which was uploaded 
several weeks ago?
Comment 3 Randy Hudson CLA 2002-06-20 19:06:27 EDT
fixed