Bug - Assertion failure in class TextEditor


#1

Hi guys,

i am new to JUCE so i might be very wrong but i believe there is a bug in the class TextEditor.

i am using Juce v1.53.107 on Mac v 10.6.8

this is the code

[code]
Label* label1;
TextEditor* texteditor1;
File myFile;
myFile = T("//Users//fsottile//Desktop//francesco//mytextfile.txt");

if (myFile.existsAsFile()) {
	String myText = myFile.loadFileAsString();
           //this works!
	label1->setText(myText,false);
	//this gives me an error
           texteditor1->setText(myText, false);
}[/code]

the error I get is:

JUCE v1.53.107
JUCE Assertion failure in /Users/fsottile/Desktop/francesco/study/audio unit/JUCE/examples/test_introducer/Builds/MacOSX/…/…/JuceLibraryCode/…/…/…/juce/amalgamation/…/src/gui/components/controls/juce_TextEditor.cpp, line 1254
Debugger() was called!


#2

You don’t seem to point label1 (or texteditor1) to anything :?


#3

sorry to make the code short i eliminated the following :

[code]label1 = new Label(T(“Label”), T(“text here”));
texteditor1 = new TextEditor(T(“Editor”));

label1->setBounds(10,10,280,20);
texteditor1->setBounds(20,160,500,200);

//HERE I OPEN THE FILE AND TRY TO READ

addAndMakeVisible(label1);
addAndMakeVisible(texteditor1);[/code]

i tried in seveal ways… but when i use the TextEditor i always get the assertion …


#4

[quote]// if you’re adding text with line-feeds to a single-line text editor, it
// ain’t gonna look right!
jassert (multiline || ! newText.containsAnyOf ("\r\n"));[/quote]

If that’s the assertion, you either need to set the textbox to be multiline (setMultiLine (true), probably what you want) or else parse the string after you read it in so it doesn’t contain “\r\n”. (string.removeCharacters ("\r\n")).


#5

yes !!!

thank you … you made my day!