Skip to content

Commit

Permalink
Fixed a leak of bubbleMessage object in juce demo
Browse files Browse the repository at this point in the history
  • Loading branch information
luigisambuy committed Aug 16, 2016
1 parent 91f2453 commit 6547452
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions examples/Demo/Source/Demos/WidgetsDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
#include "../JuceDemoHeader.h"


static void showBubbleMessage (Component* targetComponent, const String& textToShow)
static void showBubbleMessage (Component* targetComponent, const String& textToShow,
ScopedPointer<BubbleMessageComponent>& bmc)
{
BubbleMessageComponent* bmc = new BubbleMessageComponent();
bmc = new BubbleMessageComponent();

if (Desktop::canUseSemiTransparentWindows())
{
Expand All @@ -42,7 +43,7 @@ static void showBubbleMessage (Component* targetComponent, const String& textToS
AttributedString text (textToShow);
text.setJustification (Justification::centred);

bmc->showAt (targetComponent, text, 2000, true, true);
bmc->showAt (targetComponent, text, 2000, true, false);
}

//==============================================================================
Expand Down Expand Up @@ -390,6 +391,7 @@ struct ButtonsPage : public Component,

private:
OwnedArray<Component> components;
ScopedPointer<BubbleMessageComponent> bubbleMessage;

// This little function avoids a bit of code-duplication by adding a component to
// our list as well as calling addAndMakeVisible on it..
Expand All @@ -406,7 +408,8 @@ struct ButtonsPage : public Component,
showBubbleMessage (button,
"This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing "
"at a component or somewhere on the screen.\n\n"
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.");
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.",
bubbleMessage);
}

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonsPage)
Expand Down Expand Up @@ -1510,8 +1513,11 @@ class DemoTabbedComponent : public TabbedComponent
"This is a custom tab component\n"
"\n"
"You can use these to implement things like close-buttons "
"or status displays for your tabs.");
"or status displays for your tabs.",
bubbleMessage);
}
private:
ScopedPointer<BubbleMessageComponent> bubbleMessage;
};
};

Expand Down

0 comments on commit 6547452

Please sign in to comment.