I’m using JUCE 2.0.40-33-g5d353d4 in Ubuntu 13.04. I have a class that publicly inherits from Label. In my virtual void focusLost( FocusChangeType cause ) method, I run some sanity checks on the content of the label, and reformat the text when necessary. This causes a segfault in JUCE.
A simplified example of what I’m trying to do with this: if the user types 10 digits into a phone number label, I want to reformat those 10 digits into a North American “phone number” format, such as (###) ###-####, once the user moves keyboard focus to a new field.
I’ve reproduced the problem with a very simple test case, which I’ll attach here. Strangely enough, even though my code is in focusLost(), I’m seeing the segfault when I first click on the label to give it focus.
The segfault is in Label::showEditor() at juce_Label.cpp line 212. The previous line 211 results in “editor” getting set to null, and then line 212 attempts to dereference the editor pointer.