| Summary: | Wrong Text size determination when executing UI code from Display.asyncExec(... | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Lukas Dziadkowiec <i.ftelf> | ||||
| Component: | Workbench | Assignee: | Frank Appel <fr.appel> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | fr.appel | ||||
| Version: | 1.3 | ||||||
| Target Milestone: | 1.4 RC1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 169838 [details]
Demo project to reproduce
Fixed in CVS Head. Feel free to reopen if problem persists. |
Build Identifier: Eclipse 3.5.2.R35x, RAP 1.3.0.20100518-1222 I have RAP workbench application that renders UI in an Editor according to background Thread. I'm using Display.syncExec(...) and I'm creating some labels in the Editor composite. For the several few first times there is wrong TextSizeDetermination. I have traced this and for every Label and new Font there is FontProbing and StringMeasurements correctly created. The TextSizeDeterminationHandler is correctly registered as listened i the IPhaseListerner, but before RENDER phase occur, it is removed and cannot be called. Reproducible: Always Steps to Reproduce: 1. Have a simple RAP Workbench application. 2. Have an action which opens an Editor. 3. Have an separate Thread and exec Display.syncExec(.... in there. Create some labels in there. 4. For the first 1-2 times, there will be wrong text widths, because if( event.getPhaseId() == PhaseId.RENDER ) { probes = TextSizeDeterminationFacade.writeFontProbing(); calculationItems = TextSizeDeterminationFacade.writeStringMeasurements(); renderDone = true; } is not called. The TextSizeDeterminationHandler listener is removed in class TextSizeDeterminationHandler if( renderDone && event.getPhaseId() == PhaseId.PROCESS_ACTION ) { LifeCycleFactory.getLifeCycle().removePhaseListener( this ); ISessionStore session = ContextProvider.getSession(); session.removeAttribute( CALCULATION_HANDLER ); } example code in DemoActionBarAdvisor class. protected void makeActions(final IWorkbenchWindow window) { newEditorAction = new Action() { public void run() { ProgramEditorInput MyEditorInput = new MyEditorInput("yep"); try { final MyEditor editor = (MyEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(MyEditorInput, MyEditor.ID, true); editor.getComposite().getDisplay().syncExec(new Runnable() { public void run() { Label label = new Label(editor.getComposite(), SWT.NONE); label.setText("Testing lenght of the text END"); label.setFont(new Font(editor.getComposite().getDisplay(), "Courier New", 14, 0)); label.pack(); } }); } catch (PartInitException e) { e.printStackTrace(); } } };