Hi Jules,
After the deletion of a TextEditor who has had text set via setText() (text must not empty), a leak of SharedValueSourceUpdater occurs.
Hi Jules,
After the deletion of a TextEditor who has had text set via setText() (text must not empty), a leak of SharedValueSourceUpdater occurs.
Can’t reproduce that (?)
It’s also a “fake” leak anyway, because that object is ref-counted - the worst that could happen is that a single cached instance of it isn’t being deleted until after the leak-checker has run.
Strange… it happened to me yesterday in multiple projects - and now that I try to make it happen again, it doesn’t! (even tried different various other versions of the juce repo…) Oh well - I guess it’s working fine and you can disregard my topic :?
I’m seeing the same thing, with a leak in ValueSource, using the latest tip.
I’ve included the code that reproduces this. Simply commenting out “textEditor->setText (“TextEditor”);” in WindowComponent.cpp makes the leak go away.
Main.cpp
#include "../JuceLibraryCode/JuceHeader.h"
#include "WindowComponent.h"
class TestLeakApplication : public JUCEApplication
{
public:
TestLeakApplication() {}
const String getApplicationName() { return ProjectInfo::projectName; }
const String getApplicationVersion() { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() { return true; }
void initialise (const String& commandLine)
{
mainWindow = new MainWindow();
}
void shutdown()
{
mainWindow = nullptr; // (deletes our window)
}
void systemRequestedQuit()
{
quit();
}
void anotherInstanceStarted (const String& commandLine)
{
}
class MainWindow : public DocumentWindow
{
public:
MainWindow() : DocumentWindow ("MainWindow",
Colours::lightgrey,
DocumentWindow::allButtons)
{
setContentOwned (new WindowComponent(), true);
centreWithSize (getWidth(), getHeight());
setVisible (true);
}
void closeButtonPressed()
{
JUCEApplication::getInstance()->systemRequestedQuit();
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow);
};
private:
ScopedPointer<MainWindow> mainWindow;
};
START_JUCE_APPLICATION (TestLeakApplication)
WindowComponent.h
#ifndef __JUCER_HEADER_WINDOWCOMPONENT_WINDOWCOMPONENT_5E08585__
#define __JUCER_HEADER_WINDOWCOMPONENT_WINDOWCOMPONENT_5E08585__
#include "JuceHeader.h"
class WindowComponent : public Component
{
public:
WindowComponent ();
~WindowComponent();
void paint (Graphics& g);
void resized();
private:
TextEditor* textEditor;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowComponent);
};
#endif
WindowComponent.cpp
#include "WindowComponent.h"
WindowComponent::WindowComponent ()
: textEditor (0)
{
addAndMakeVisible (textEditor = new TextEditor ("new text editor"));
textEditor->setMultiLine (false);
textEditor->setReturnKeyStartsNewLine (false);
textEditor->setReadOnly (false);
textEditor->setScrollbarsShown (true);
textEditor->setCaretVisible (true);
textEditor->setPopupMenuEnabled (true);
textEditor->setText ("TextEditor");
setSize (600, 400);
}
WindowComponent::~WindowComponent()
{
deleteAndZero (textEditor);
}
//==============================================================================
void WindowComponent::paint (Graphics& g)
{
g.fillAll (Colours::white);
}
void WindowComponent::resized()
{
textEditor->setBounds (16, 24, 150, 24);
}
Ah! Under certain conditions it could get itself tied up in circular references. Thanks! Should be ok now.