Exception when changing Editor.Document

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
Hi,

When changing the Document property on a SyntaxEditor control, I sometimes get this exception:

Index was outside the bounds of the array.
at be.b(Int32 A_0)
at bj.a(Int32 A_0)
at ActiproSoftware.SyntaxEditor.DisplayLineCollection.e(Int32 A_0)
at ActiproSoftware.SyntaxEditor.EditorView.a(Boolean A_0, Boolean A_1)
at ActiproSoftware.SyntaxEditor.EditorView.ArrangeCore()
at ActiproSoftware.WinUICore.UIElement.Arrange(Rectangle newBounds)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.ArrangeCore()
at ActiproSoftware.WinUICore.UIControl.Arrange(Rectangle newBounds)
at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.a(co A_0)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.a(Document A_0)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.set_Document(Document value)

I can not reproduce this in the example application. Any suggestions?

Erik Pepping

Comments (8)

Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
Sorry to bother you some more, but I have another internal SyntaxEditor exception, which is hard to reproduce at will:

Collection was modified; enumeration operation may not execute
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at ActiproSoftware.SyntaxEditor.OutliningNode.a(String A_0)
at ActiproSoftware.SyntaxEditor.OutliningNode.CollapseDescendants(String key)
at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetSyntaxLanguage.OnDocumentAutomaticOutliningComplete(Document document, DocumentModificationEventArgs e)
at ActiproSoftware.SyntaxEditor.Document.a(TextRange A_0, AutomaticOutliningBehavior A_1, DocumentModification A_2, Boolean A_3)
at ActiproSoftware.SyntaxEditor.Document.a(ISemanticParseData A_0, TextRange A_1, Boolean A_2)
at ActiproSoftware.SyntaxEditor.Document.ActiproSoftware.SyntaxEditor.ISemanticParseDataTarget.NotifySemanticParseComplete(SemanticParserServiceRequest request)
at ActiproSoftware.SyntaxEditor.SemanticParserService.a(SemanticParserServiceRequest A_0)

Regards,

Erik Pepping
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Erik,

I've been trying to dupe the first one and haven't been able to. Based on the stack trace, I believe it is trying to get the character layout for a display line thinking there are a certain number of characters (the old amount) but the document text has been changed and so a character layout index is out of range.

I would say try to experiment with various document sizes, scrollbar positions (scrolled right or down), and any other SyntaxEditor options you may have set. This sort of thing we really need to be able to dupe to be able to fix. If you are able to get it to happen in a small sample project of your own, then email it over and we can debug it.

As for the CollapseDescendants issue, I've modified the loop that is throwing the exception to do more bounds checking and not be a foreach. Tihs will be in the next maintenance release.


Actipro Software Support

Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
Thanks for the feedback.

The first one seems to happen when the user switches documents very fast (from C# add-on language to HTML language documents). I will try to simulate this in the example application and see if it happens there also.

Btw I did have another one, which was easier to fix by removing the documents with "dotNetProjectResolver.Remove" before disposing the documents themselves. Perhaps this one could by prevented by some more null checking?

at ActiproSoftware.SyntaxEditor.Document.a(ISemanticParseData A_0, TextRange A_1, Boolean A_2)
at ActiproSoftware.SyntaxEditor.Document.ActiproSoftware.SyntaxEditor.ISemanticParseDataTarget.NotifySemanticParseComplete(SemanticParserServiceRequest request)
at ActiproSoftware.SyntaxEditor.SemanticParserService.a(SemanticParserServiceRequest A_0)
at ActiproSoftware.SyntaxEditor.SemanticParserService.c()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Erik Pepping.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
For your other one, I'm wondering if by disposing the document it was removing the language reference but the callback occurred after the dispose. There is some stuff that calls the language in that method. I'll add code to try and look for this scenario and ensure there is a language still available. Normally there always is but the multi-threading introduces all kinds of fun issues. :)


Actipro Software Support

Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
Hi,

Just had another exception:

System.IndexOutOfRangeException occurred
Message="Index was outside the bounds of the array."
Source="ActiproSoftware.SyntaxEditor.Net20"
StackTrace:
at bf.b(Int32 A_0)
at bk.a(Int32 A_0)
at ActiproSoftware.SyntaxEditor.DisplayLineCollection.e(Int32 A_0)
at ActiproSoftware.SyntaxEditor.EditorView.a(Boolean A_0, Boolean A_1)
at ActiproSoftware.SyntaxEditor.EditorView.ArrangeCore()
at ActiproSoftware.WinUICore.UIElement.Arrange(Rectangle newBounds)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.ArrangeCore()
at ActiproSoftware.WinUICore.UIControl.Arrange(Rectangle newBounds)
at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.a(co A_0)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.a(Document A_0)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.set_Document(Document value)

This sometimes happens when a new document is assigned to the Editor while it was displaying another document.

I hope this is something you guys can reproduce/fix.

Erik Pepping
Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
I debugged this some more and came to the conclusion that the document I'm trying to assign to the Editor is not finished with the semanticparser. The document created has been added to the dotNetProjectResolvers SourceProjectContent.

I implemented a WaitTillParserFinished with these conditions before assigning it to the editor:
while (SemanticParserService.IsBusy || SemanticParserService.PendingRequestCount > 0)

This fixes this problem.

Erik Pepping.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Could you throw together a tiny test project that shows the exception occur and email that over? That would help a lot.


Actipro Software Support

Posted 17 years ago by Erik Pepping - RADVenture B.V
Avatar
It will not be easy to reproduce this exception in the example project, because it only seems to happen if we create a lot documents and "add" those to the dotNetProjectResolver.SourceProjectContent.

But I will see if I can reproduce something similar in the example project.

Erik Pepping
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.