Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 184696

Summary: IllegalStateException when redrawing the column
Product: [Eclipse Project] Platform Reporter: Peter Ossipov <petik>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
The way labels on a column are drawn none

Description Peter Ossipov CLA 2007-04-30 09:44:59 EDT
Build ID: M20070212-1330

Steps To Reproduce:
I am not sure what to do with this exception - it might be that I am doing something wrong. I have an AbstractTextEditor that uses ProjectionViewer and based on the document positions I am drawing the rulers as you can see in the attachement. So, the positions are updated and as I am listening to document events I am forcing the column to be redrawn like column.redraw. This results in every so often the attached bunch of exceptions to fall out which I do not fully understand the cause.
If I do it this way
            try
            {
                column.redraw();
            }
            catch (Throwable e)
            {
                // do not really know what to do with this one and why it appears
            }
Then everything works fine. 
I surely can reproduce the problem in my application. I event tried the lates build of 3.3, but it is still there...

More information:
ERROR - Unhandled event loop exception
ERROR - java.lang.IllegalStateException
java.lang.IllegalStateException
	at org.eclipse.jface.text.projection.ProjectionMapping.toImageLine(ProjectionMapping.java:478)
	at org.eclipse.jface.text.TextViewer.modelLine2WidgetLine(TextViewer.java:4740)
	at org.eclipse.jface.internal.text.JFaceTextUtil.modelLineToWidgetLine(JFaceTextUtil.java:221)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.doPaint(LineNumberRulerColumn.java:654)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.doubleBufferPaint(LineNumberRulerColumn.java:606)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.redraw(LineNumberRulerColumn.java:760)
	at com.astrac.as.client.ide.core.editors.language.LanguageTextEditor.adaptToLabelsSetChanges(LanguageTextEditor.java:878)
	at com.astrac.as.client.ide.core.editors.language.LanguageTextEditor.access$2(LanguageTextEditor.java:872)
	at com.astrac.as.client.ide.core.editors.language.LanguageTextEditor$4.documentChanged(LanguageTextEditor.java:739)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:699)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:672)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:657)
	at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:722)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1080)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1090)
	at org.eclipse.jface.text.projection.ProjectionTextStore.replace(ProjectionTextStore.java:111)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1073)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1090)
	at org.eclipse.jface.text.projection.ProjectionDocument.replace(ProjectionDocument.java:619)
	at org.eclipse.jface.text.DefaultDocumentAdapter.replaceTextRange(DefaultDocumentAdapter.java:243)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5738)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6447)
	at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2094)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5024)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5049)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4789)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1932)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.astrac.as.client.ide.core.application.ApplicationAsClient.run(ApplicationAsClient.java:25)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
ERROR - Unhandled event loop exception
ERROR - Failed to execute runnable (java.lang.IllegalStateException)
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalStateException)
	at org.eclipse.swt.SWT.error(SWT.java:3374)
	at org.eclipse.swt.SWT.error(SWT.java:3297)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.astrac.as.client.ide.core.application.ApplicationAsClient.run(ApplicationAsClient.java:25)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.IllegalStateException
	at org.eclipse.jface.text.projection.ProjectionMapping.toImageLine(ProjectionMapping.java:478)
	at org.eclipse.jface.text.TextViewer.modelLine2WidgetLine(TextViewer.java:4740)
	at org.eclipse.jface.internal.text.JFaceTextUtil.modelLineToWidgetLine(JFaceTextUtil.java:221)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.doPaint(LineNumberRulerColumn.java:654)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.doubleBufferPaint(LineNumberRulerColumn.java:606)
	at org.eclipse.jface.text.source.LineNumberRulerColumn.redraw(LineNumberRulerColumn.java:760)
	at org.eclipse.jface.text.source.LineNumberRulerColumn$1.run(LineNumberRulerColumn.java:343)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	... 20 more
Comment 1 Peter Ossipov CLA 2007-04-30 09:47:01 EDT
Created attachment 65386 [details]
The way labels on a column are drawn
Comment 2 Dani Megert CLA 2007-04-30 09:49:29 EDT
It would help if you could provide a test case or code snippet that allows us to reproduce it based on the Eclipse SDK.

*** This bug has been marked as a duplicate of bug 66809 ***

*** This bug has been marked as a duplicate of bug 66809 ***
Comment 3 Peter Ossipov CLA 2007-04-30 09:55:00 EDT
In addition I have to say that I have folding in my viewer and if I comment the following line from this article everything works fine
http://www.eclipse.org/articles/Article-Folding-in-Eclipse-Text-Editors/folding.html

private Annotation[] oldAnnotations;
public void updateFoldingStructure(ArrayList positions)
{
   Annotation[] annotations = new Annotation[positions.size()];

   //this will hold the new annotations along
   //with their corresponding positions
   HashMap newAnnotations = new HashMap();

   for(int i = 0; i < positions.size();i++)
   {
      ProjectionAnnotation annotation = new ProjectionAnnotation();

      newAnnotations.put(annotation, positions.get(i));

      annotations[i] = annotation;
   }
   // COMMENT THIS LINE AND EVERYTHING WORKS FINE
   //annotationModel.modifyAnnotations(oldAnnotations, newAnnotations,null);

   oldAnnotations = annotations;
}
Comment 4 Peter Ossipov CLA 2007-04-30 09:56:10 EDT
Well, I guess it might be the case that the calculating of the folding stuff is done in a separate thread and I have seen no synchronization blocks at all.
Comment 5 Peter Ossipov CLA 2007-04-30 09:58:58 EDT
(In reply to comment #2)
> It would help if you could provide a test case or code snippet that allows us
> to reproduce it based on the Eclipse SDK.
> 
> *** This bug has been marked as a duplicate of bug 66809 ***
> 
> *** This bug has been marked as a duplicate of bug 66809 ***
> 
Daniel, I would really like to co-operate, but I can see it will be really difficult to supply you with a snippet or a test case. Is there anything else I can provide?
Comment 6 Dani Megert CLA 2007-04-30 10:10:19 EDT
Maybe you can downscale your editor so that you can attach it here?
Comment 7 Peter Ossipov CLA 2007-05-01 04:36:37 EDT
(In reply to comment #6)
> Maybe you can downscale your editor so that you can attach it here?
> 

Okay, I am gonna try