Bug 250255 - LightweightSystem#setUpdateManager does't dispose old UpdateManager
Summary: LightweightSystem#setUpdateManager does't dispose old UpdateManager
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-09 06:05 EDT by Heiko Böttger CLA
Modified: 2008-10-09 06:05 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 Heiko Böttger CLA 2008-10-09 06:05:00 EDT
Build ID: M20080911-1700

Steps To Reproduce:
public class EditableFigureCanvasTest extends TestCase {
  private static final class TestUpdateManager extends UpdateManager {
    @Override
    public void addDirtyRegion(IFigure figure, int x, int y, int w, int h) {
      
    }

    @Override
    public void addInvalidFigure(IFigure figure) {
      
    }

    @Override
    public void performUpdate() {
      
    }

    @Override
    public void performUpdate(Rectangle exposed) {
      
    }

    @Override
    public void setGraphicsSource(GraphicsSource gs) {
      
    }

    @Override
    public void setRoot(IFigure figure) {
      
    }

    @Override
    public boolean isDisposed() {
      return super.isDisposed();
    }
  }

  @Test
  public void test_setUpdateManager() {
    //test if old updateManager is disposed
    Display.getDefault().syncExec(new Runnable() {
      public void run() {
        //test if bug still exists
        LightweightSystem lightweightSystem = new LightweightSystem();
        TestUpdateManager um = new TestUpdateManager();
        lightweightSystem.setUpdateManager(um);
        lightweightSystem.setUpdateManager(new TestUpdateManager());
        assertFalse("bug is fixed, remove workaround",um.isDisposed());
           }
    });
  }
}

To Produce a widget is disposed exception setup a canvas:
1. create a canvas
2. add an update listener to the UpdateManager
3. access the canvas inside listener
4. dispose canvas after replacing the UpdateManager


More information:
If the widget is disposed after setting the new UpdateManager, the old UpdateManager is not disposed and will execute its pending updates and validations. This will result in a widget is disposed error.