Character Limit in Projucer 'Member Initialisers' Field


#1

Greetings,

I’ve got a UI class with lots of components I need to initialize. I usually try to do as much of that as possible in the member initializer list, but it seems that this time I’ve surpassed the hard-coded limit on number of characters (2048) for that field (from ‘jucer_JucerDocumentEditor.cpp’):

//==============================================================================
class ComponentInitialisersProperty : public ComponentTextProperty
{
public:
ComponentInitialisersProperty (JucerDocument& doc)
: ComponentTextProperty (“Member intialisers”, 2048, true, 0, doc)
{
preferredHeight = 24 * 3;
}

    void setText (const String& newText) override    { document.setVariableInitialisers (newText); }
    String getText() const override                  { return document.getVariableInitialisers(); }
};

I’m still making use of the Jucer’s component editor for this class, so the code is bound to get overridden when the Jucer overwrites that section. I guess for now I’ll just change the limit in my local copy but it would be cool if this could be increased to something more generous, say 16384 or something just to be safe. Any particular reason it was set that low?

Also, I just noticed there’s a typo in that field’s label (also bolded) :wink:

Thanks for your time!


#2

OK this is fixed on develop now. Be sure to re-build the projucer.


#3

Thank you Fabian! However this seems to have revealed (or perhaps caused) other strange behavior when the code gets written to the source file.

I’ve been testing some things out – so far the problem only seems to arise when I use aggregate initialization for std::arrays. I made a dummy project to demonstrate what I’m talking about.

For the GUI component Test.cpp, you should be able to see many more lines saved in the member initializer field than the Projucer actually writes to the file. Meanwhile in Test2.cpp (roughly the same thing but without std::array / aggregate initialization), all the lines are written to the file properly.

Jucer file:
Test.cpp (failure)
Test2.cpp (succss)

Full zipped project here

Any ideas?


#4

Seems that the Projucer doesn’t work well with curly braces. I’ll have a look…


#5

Cool, thanks for looking into it!


#6

Nothing seems wrong with the project you sent me and the newest Projucer. I’m I missing something.


#7

I just tried again with the latest updates on both develop and master branches, it’s still happening on my end.

Here’s what I’m seeing:

Pasting the following text into the Member Initialisers field for a GUI component file (test.cpp) and saving, (save, save all, save project and open in IDE, etc)…

sliders{{new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox)}},
buttons{{new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched)}},
labels{{new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”))}}

…results in the following text being written to that .cpp file:

sliders{{new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox),
new Slider(Slider::SliderStyle::RotaryHorizontalVerticalDrag, Slider::TextEntryBoxPosition::NoTextBox)}},
buttons{{new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched),
new DrawableButton(“button”, DrawableButton::ButtonStyle::ImageStretched)}},
labels{{new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”)),
new Label(“label”, TRANS(“label”))}}

The full text gets saved in the jucer file just fine, but text is dropping between those curly braces. So far it appears that the dropped chunks of text are arguments within the curly braces – words aren’t being cut in half, but comma-separated sections are left out. Here’s another example I’ve observed:

arrayOfScopedPointers{{new Thing(instance1Arg1,
instance1Arg2, instance1Arg3),
new Thing(instance2Arg1,
instance2Arg2, instance2Arg3)}},

…the bold text is missing when the jucer writes it to the file. This is on a Mac running El Capitan, just FYI.


#8

OK this is fixed now on develop. Thanks for reporting.


#9

Thanks so much Fabian, much appreciated!