Possible Toolbar bug


I was messing with the Toolbar and found out that setting a default item set for the toolbar with no separators/resizers/spacers causes the items to have zero size.
Specifically, const double scale = targetAmountOfExtraSpace / availableExtraSpace; in juce_StretchableObjectResizer.cpp yields 0/0 and the calculations then continue with scale = 0 (shouldn’t it crash?).

To reproduce simply comment out everything but the first item in WidgetsDemo.cpp:

void getDefaultItemSet (Array <int>& ids) { // This returns an ordered list of the set of items that make up a // toolbar's default set. Not all items need to be on this list, and // items can appear multiple times (e.g. the separators used here). ids.add (doc_new); //ids.add (doc_open); //ids.add (doc_save); //ids.add (doc_saveAs); //ids.add (spacerId); //ids.add (separatorBarId); //ids.add (edit_copy); //ids.add (edit_cut); //ids.add (edit_paste); //ids.add (separatorBarId); //ids.add (flexibleSpacerId); //ids.add (customComboBox); //ids.add (flexibleSpacerId); //ids.add (separatorBarId); //ids.add (juceLogoButton); }

Am I doing something wrong here or is this some sort of bug?

Thanks - yes, I think it does need something to handle that case, I’ll take a look at that!