DrawableRectangle bug


Using a DrawableRectangle as the image for a DrawableButton doesn’t work. For example modifying JuceDemo as such reproduces it:

+DrawableRectangle rect;
+rect.setRectangle (Rectangle<float> (0, 0, 50.0f, 50.0f));
+rect.setFill (Colours::red);
+rect.setStrokeFill (Colours::green);
+rect.setStrokeThickness (3.0f);

DrawableButton* db = addToList (new DrawableButton (String (i + 5) + " points", DrawableButton::ImageAboveTextLabel));
-db->setImages (&normal, &over, 0);
+db->setImages (&rect, &over, 0);

Instead of nice red/green rectangles the buttons have no image.

The bug seems to lie in DrawableRectangle's copy constructor, and adding a call to rebuildPath() within it seems to solve it.


Now also reported in the bug tracker at https://github.com/julianstorer/JUCE/issues/95


Thanks, sorry we hadn’t noticed this post before… Yep, definitely just a case of adding a call to rebuildPath, will push that right away!