# DrawableRectangle bug

**URL:** <https://forum.juce.com/t/drawablerectangle-bug/18302>\
**Category:** General JUCE discussion\
**Created:** [July 4, 2016, 10:23am UTC](https://forum.juce.com/t/drawablerectangle-bug/18302 "2016-07-04T10:23:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yairadix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yairadix/32/1114_2.png) [@yairadix](https://forum.juce.com/u/yairadix)\
**Post date:** [July 4, 2016, 10:23am UTC](https://forum.juce.com/t/drawablerectangle-bug/18302/1 "2016-07-04T10:23:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yairadix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yairadix/32/1114_2.png) [@yairadix](https://forum.juce.com/u/yairadix)\
**Post date:** [August 18, 2016, 11:53am UTC](https://forum.juce.com/t/drawablerectangle-bug/18302/2 "2016-08-18T11:53:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [August 18, 2016, 1:07pm UTC](https://forum.juce.com/t/drawablerectangle-bug/18302/3 "2016-08-18T13:07:37Z")

</div>

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!
