Mess with BubbleMessageComponent class

Hello guys !

We talked about that a few times, for example there : BubbleMessageComponent not deleted (using last tip)

There are a few things that are wrong with the BubbleMessageComponent class. First, in the JuceDemo example project, with the Widgets / Button demo, if we try to close the app while a BubbleMessageComponent is still visible, an assertion is unleashed.

Then, I have very often issues in some personal plug-in projects using that class, when the PluginEditor is closed with a BubbleMessageComponent still visible, or fading out at the same moment. I have either the BubbleMessageComponent which stays visible even if the plug-in has been removed, or a crash. I have not found a good solution yet, that’s why I’m posting this message…

Would it be possible to have an example of good practices to use this class, or maybe some corrections if needed ? See the destructor of the class maybe… And of course, it would be great to solve the issues in the JuceDemo project.

Thanks in advance !
Ivan

Hey Ivan!

I fixed the issue in the JUCE demo, as Jules was saying in the post you cited, it was a simple issue of the code not cleaning up. The showBubbleMessage (Component* targetComponent, const String& textToShow) method was using a raw pointer to create a new BubbleMessageComponent(); which then was not destroyed once the class using it got destructed.

The fix just involed using a ScopedPointer, which destroys the element that it points to once it goes out of scope. Specifically, in the JUCE demo, I created a ScopedPointer member variable for every class using it and then pass it by reference to showBubbleMessage (Component* targetComponent, const String& textToShow, ScopedPointer<BubbleMessageComponent>& bmc) as an extra third argument.

I think that this is a good practice and that it might fix the issues in your personal projects. Let me know if this helps!

Hello and thanks for your answer ! You’ll push the change on GitHub ? I have tried to follow your idea, I did everything as right as I could, but I have still the leak problem if I quit the app when the BubbleMessage is visible… I have no leaks if I wait for the BubbleMessage to diseappear…

Yes I just pushed the change to the develop branch! I also set the “deleteSelfAfterUse” argument of showAt() to false so that there are no double deletion issues, check if that helps.

Hello again !

So I have tried your code, and it performs better than mine before, but there is still an issue inside. I have set the fadeOutLength to 500 ms this way in the static function :

bmc = new BubbleMessageComponent(500);

Then, if I try to close the app when the bmc is visible, everything works fine unless I do so while the component is fading out. In this case, I still have an issue with an assertion or a crash.

Do you know how that might be fixed ? Thanks again in advance :wink:

Ok! This can be solved if you add animator.cancelAllAnimations (false) in the destructor of Desktop. I pushed this change to develop.

That has just solved the issue on the JUCE Demo and some long time issues in my plug-ins ! Thanks a lot !!

1 Like