OSX : image button crash Logic 8?


I have a repeatable crashe occuring with image button and Logic 8, when trying to remove the plugin(or quit logic) while the plugin’s gui is still visible.

In Jucer I created a new image button and then copied that code (function & binary ressource) into the JuceDemoPlugin of the trunk.

The crash log always show :

Thread 0 Crashed:
0 libSystem.B.dylib 0x92438e42 __kill + 10
1 libSystem.B.dylib 0x924ab23a raise + 26
2 libSystem.B.dylib 0x924b7622 __abort + 97
3 libSystem.B.dylib 0x924b768a _cproc_fork_child + 0
4 com.apple.logic.pro 0x002b37ff 0x1000 + 2828287
5 libSystem.B.dylib 0x924372bb _sigtramp + 43
6 …rialsoftware.JuceDemoPlugin 0x22b88b8f juce::ImageButton::deleteImages() + 93 (juce_amalgamated.cpp:43227)

If I close the plugin’s GUI then quit/remove, it’s all fine. Any hints ?



Looks like a classic dangling pointer to me, you’ve probably just deleted the image and then let the button try to delete it.

Hello Jules,

Thanks for the prompt reply as always.

Probably the problem is like you described. But I only copy/paste into the JuceDemoPlugin a few elements that were generated by the JUCER itself.
So could you please let me know which one could cause a problem ?
Here’s the 6 things I try to add to jucedemoplugin:

1- in public :
static const char
static const int prefs_about_pngSize;
static const char
static const int prefs_misc_pngSize;
static const char
static const int jules_jpgSize;

2- in private : ImageButton* imageButton;

3- in constructor :
addAndMakeVisible (imageButton = new ImageButton (T(“new button”)));
imageButton->setImages (false, true, true,
ImageCache::getFromMemory (prefs_about_png, prefs_about_pngSize), 1.0000f, Colour (0x0),
ImageCache::getFromMemory (prefs_misc_png, prefs_misc_pngSize), 1.0000f, Colour (0x0),
ImageCache::getFromMemory (jules_jpg, jules_jpgSize), 1.0000f, Colour (0x0));

4- in destructor (I’ve also tried to comment it out) :
deleteAndZero (imageButton);

5- in resized : imageButton->setBounds (168, 72, 64, 64);

6- And finally the (trimmed) binary images :

static const unsigned char resource_DemoEditorComponent_prefs_about_png[] = { 137,80,…
const char* DemoEditorComponent::prefs_about_png = (const char*) resource_DemoEditorComponent_prefs_about_png;
const int DemoEditorComponent::prefs_about_pngSize = 1819;

static const unsigned char resource_DemoEditorComponent_prefs_misc_png[] = { 137,80,78,71,13,10,…

const char* DemoEditorComponent::prefs_misc_png = (const char*) resource_DemoEditorComponent_prefs_misc_png;
const int DemoEditorComponent::prefs_misc_pngSize = 6162;

static const unsigned char resource_DemoEditorComponent_jules_jpg[] = { 255,216,255,224,0,16,74,70…

const char* DemoEditorComponent::jules_jpg = (const char*) resource_DemoEditorComponent_jules_jpg;
const int DemoEditorComponent::jules_jpgSize = 24218;

Is there something obvious that I would have overlooked ?

Any help would be much appreciated.
If more convenient, I can also send the xcode project.



PS : from a quick test, I didn’t had that crash with 1.46…

Maybe it’s the imagebutton that’s being deleted twice? A quick step-through with the debugger should make it pretty obvious what’s going on.


Well, I’m not deleting it myself at least. I only added the above code to the juce demo plugin, nothing else. And considering that the same code do work in 1.46, wouldn’t that be a bug in juce tip ?

It sound like you don’t really want to dig into it right ? :lol:
But if it’s indeed image button that it broken in the tips for audiounit, wouldn’t you mind to try to replicate ? I mean you may hear again about that one sooner or later anyway…

Do someone has the image button working in an AU plugin using the tip ?

For myself, I’ve tried everything I could think of, within my limited C++ skill. So for now I’ll try to use another class than image button.
Though if someone has it working with the tip, then I’d be very interested to see how it’s implemented.



I’m reluctant to spend any time on this because a bug in ImageButton would have crashed all of my own projects and been noticed immediately! It’ll be something dumb like, e.g. the demo code does a deleteAllChildComponents() just before you delete your button?

Hello Jules,

Yes, commenting out deleteAllChildComponents() helped as there is no more crash now ! . :smiley:

Though there is still mystery for me on where does that second call to delete imagebutton comes from (as the crash happen even if the individual deleteAndZero (imageButton); call is commented out as well.)

And the tip also changed behavior in regards to 1.46, considering the same source code don’t crash with 1.46 !

So to resume (i may help someone else new like me)
If I use image button and whatever there is deleteAllChildComponents() or deleteAndZero (imageButton); --> crash on de-instantiation

It’s working only when there is no call AT ALL to delete image button in the destructor.
Weird, but fine once it’s known…

Thanks Jules,


Have you tried a breakpoint in the ImageButton destructor? Should be pretty easy to catch it there.

put back deleteAllChildComponents
and put a breakpoint in the destructor and see where those are called from.

Simple as that.