I have a window with a CodeEditorComponent with an associated CodeDocument). It reads and displays files. If i open a new document and replacing previous text (using CodeDocument::loadFromStream()), it will hang IF i previously scrolled the old document to a position further down than what is available in the new document it seems (ie., the new document is smaller than the old).
The infinite loop is here:
for (;;) { codeTokeniser->readNextToken (*t); if (t->getLine() >= targetLine) break; if (t->isEOF()) return; }
inside "void CodeEditorComponent::updateCachedIterators (int maxLineNum)". It is called from scrollbarMoved->scrollToLineInternal iirc.
The code is using the standard CPlusPlusTokenizer. Stepping through the first couple of lines:
template <typename Iterator> static int readNextToken (Iterator& source) { source.skipWhitespace(); const juce_wchar firstChar = source.peekNextChar();
"firstChar" is always set to zero ('\0'), from which the tokenizer returns tokenType_error. Even if i wrote a custom tokenizer, there's no way to report the error back (return value isn't checked) beyond throwing an exception and crashing the application.
e: problem temporarily solved by calling CodeEditorComponent::ScrollToLine(0) before loading new text. Shouldn't this be default behaviour?