# Closing the Plug-In makes the DAW crash

**URL:** <https://forum.juce.com/t/closing-the-plug-in-makes-the-daw-crash/26700>\
**Category:** Audio Plugins\
**Created:** [March 8, 2018, 8:58am UTC](https://forum.juce.com/t/closing-the-plug-in-makes-the-daw-crash/26700 "2018-03-08T08:58:02Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [March 9, 2018, 9:15am UTC](https://forum.juce.com/t/closing-the-plug-in-makes-the-daw-crash/26700/11 "2018-03-09T09:15:08Z")

</div>

Rather than adding a `SliderAttachment` member to each `Slider`, why don’t you keep around this kind of `struct` for whenever you need such a coupling:

```
struct SliderWithAttachment
{
    ScopedPointer <Slider> slider;
    ScopedPointer <SliderAttachment> attachment;
};

```

This way, in your Editor you can simply add a member like:

```
SliderWithAttachment knob;

```

and voila, you have the `knob.slider` and the `knob.attachment` automatically deleted in the correct order, and also nicely bound together making the code more readable IMHO

---

_[View the full topic](https://forum.juce.com/t/closing-the-plug-in-makes-the-daw-crash/26700)._
