ScopedPointer and Introjucer

Why does the Introjucer do this:

ScopedPointer<ToggleButton> toggleButton;

MyComponent::MyComponent ()
    addAndMakeVisible (toggleButton = new ToggleButton ("new toggle button"));
    toggleButton->addListener (this);


    setSize (600, 400);

    //[Constructor] You can add your own custom stuff here..

    //[Destructor_pre]. You can add your own custom destruction code here..

    toggleButton = nullptr;

    //[Destructor]. You can add your own custom destruction code here..

Because the toggleButton is a scopedPointer, why would we need to put ‘toggleButton = nullptr’, it will go out of scoped and get deleted.
Just wondering as i’m using the Introjucer now a lot while converting our Juce 1.50 based project, just wondering if i’m not making wrong assumptions.

Yes - in this case (and most cases) it’d work just the same without needing to clear the pointer, of course.

The reason I added the explicit “= nullptr” statements is that the old code-generator used to call “deleteAndZero” there, so I needed to provide the same behaviour in case people had put code in their [Destructor] user-code section following the destruction of the child comps which would fail if the child comps still existed at that point.

ok, thanks Jules. Already thought it would be something along those lines. Just checking if i wasn’t missing something.