Hey JUCEists! I have an imageButton in a plugin that is just a placeholder for displaying different images. I have the various alternative images loaded as resources in the Jucer project and I am trying to load the new images with something like this:
const char* newImage;
//some stuff for choosing which image will be loaded
newImage = pottedPlant_png;
newSize = pottedPlant_pngSize;
ib_micPic->setImages (false, true, true,
ImageCache::getFromMemory (newImage, newSize), 1.0000f, Colour (0xf0ffff),
Image(), 1.0000f, Colour (0xffffff),
Image(), 1.0000f, Colour (0xffffff));
The call hangs seemingly from the ‘getFromMemory’ section. Any reason this shouldn’t work? Am I doing something stupid?
Well, if it hangs, that’s what debuggers are for!
BTW: all your colours have alpha=0, which is probably not what you intended.
Were you able to solve it…? There’s nothing much wrong with the code… Probably the ‘newImage’ in the ‘getFromMemory()’ isn’t getting a proper image… Just debug it and check whether you are getting a proper image within your pointer… That’s the culprit for me… All the best then…
Sorry, I wasn’t very specific before. With the GDB debugger, dubbing hangs even when trying to step into the setImages() function. Using LLVM I was once able to step into ImageCache::getFromMemory just enough to see that the image was formatted and loaded correctly but it hanged while trying to step out of the function. Every other time it also hangs stepping in. I did manage to get this crash report out of the time I could step in:
0 libsystem_c.dylib 0x9050ea1e OSAtomicAdd32Barrier$VARIANT$mp + 10
1 com.yourcompany.Kalliope_plugIn 0x16829cdc juce::Atomic<int>::get() const + 28 (juce_Atomic.h:248)
2 com.yourcompany.Kalliope_plugIn 0x16829cac juce::ReferenceCountedObject::getReferenceCount() const + 28 (juce_ReferenceCountedObject.h:91)
3 com.yourcompany.Kalliope_plugIn 0x16829983 juce::ReferenceCountedObject::decReferenceCount() + 35 (juce_ReferenceCountedObject.h:84)
4 com.yourcompany.Kalliope_plugIn 0x16a8e9e0 juce::ReferenceCountedObjectPtr<juce::ImagePixelData>::operator=(juce::ImagePixelData*) + 96 (juce_ReferenceCountedObject.h:300)
5 com.yourcompany.Kalliope_plugIn 0x16a8e8b6 juce::ReferenceCountedObjectPtr<juce::ImagePixelData>::operator=(juce::ReferenceCountedObjectPtr<juce::ImagePixelData> const&) + 38 (juce_ReferenceCountedObject.h:258)
6 com.yourcompany.Kalliope_plugIn 0x169fe347 juce::Image::operator=(juce::Image const&) + 39 (juce_Image.cpp:208)
7 com.yourcompany.Kalliope_plugIn 0x16b249a3 juce::ImageButton::setImages(bool, bool, bool, juce::Image const&, float, juce::Colour const&, juce::Image const&, float, juce::Colour const&, juce::Image const&, float, juce::Colour const&, float) + 163 (juce_ImageButton.cpp:54)
...my setImages() call
Also, I aren’t the alpha=0 properties only for the color overlay? Since I’m just trying to display an image, I don’t want any highlights or over/click graphics manipulation.
Forgive my ignorance, but is there an easier way to do this? If I use a ‘graphics’ image in the Jucer, I can’t change the picture at runtime. I don’t want to create multiple imageButtons and use setVisible every time I change the picture. Thanks for the help!
Eh? What OS are you using?
i have the privilege of having my first Mac experience on 10.7 with xcode 4.3. It’s been a blast so far.
Well, looks like you’ve got some mashed-up memory going on there. I’ve no idea how you’d get that to fail unless the program state is already corrupt by the time it gets to that point. Trying to reproduce the same problem in a stand-alone test app might be a good idea.