Leaked objects when writing an image to a png file


#1

Hello,

I have a very simple command line program that creates an image with text and writes it to a png file.

It works fine, but leaks many objects as it exits. Can anyone give me insight as to what I’m doing wrong here?

Thank you!

int main (int argc, char* argv[])
{
    FileOutputStream fstream ( File ("~/Desktop/test.png") );
    PNGImageFormat pngWriter;
    int npixelsX = 600;
    int npixelsY = 200;
    Image myImage (Image::ARGB, npixelsX, npixelsY, true);
    Graphics g (myImage);
    const Rectangle<int> area (0, 0, npixelsX, npixelsY);

    g.setFont (20.0f);
    g.setColour (Colours::black);
    g.drawFittedText ("This program leaks objects", area, Justification::centred, 2);
    pngWriter.writeImageToStream (myImage, fstream);

    return 0;
}

#2

This is related to this thread:

Described here:
https://juce.com/doc/classScopedJuceInitialiser__GUI

I think putting this line as the first thing and forget about it:

ScopedJuceInitialiser_GUI juceInit;

Worked in my case.

Good luck!


#3

Wow that did it!

Thank you!