| Summary: | DeferredUpdateManager should not use Display.getCurrent() | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Hannes Niederhausen <hniederhausen> |
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | 3.2.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Hannes Niederhausen
GEF and draw2d are not thread safe. Therefore, you can not access your editparts or figures from multiple threads. If you could do this, you will end up with ArrayIndexOutOfBounds and other exceptions. You must use syncExec or asyncExec to access your editparts from the appropriate thread. Is this the only issue you are having with this use case? Display.getCurrent() is null? The use case is: I started programming a kind of UML Editor and wanted to syncronize with the jdt. The reconciler, which fires the code change events works in a different thread and so my listener refreshs the editparts in the same thread. After using Display.syncExec I had no other problems. I just wondered why I have to start a new thread only to allow draw2d to start another thread. If you refresh your editparts in one thread, and the Main thread is in the middle of editing the model, painting, laying out, performing hit-testing for the mouse, or many other things which involve reading or writing the figures, you will have subtle threading issues. Debugging the NPE you saw is much easier than tracking down thread-related bugs. JDT has to do the same thing when they respond to these notifications. If they are updating an SWT tree, they use (a)syncExec. |