I wrote a small video feed that loads images from a web url as fast as it can. The high level code is something like this:
void VideoFeedImageUrl::threadedFunction()
{
while (isThreadRunning())
{
if (loader->loadImage(url)){
lock();
pixels = loader->getPixelsRef();
unlock();
ofSleepMillis(10);
}
}
}
I had errors before so I turned loader
—which is an ofImage
—into a pointer, so I could control destruction:
class VideoFeedImageUrl : public VideoFeed
{
public:
~VideoFeedImageUrl() { waitForThread(true); delete loader;}
void threadedFunction() ;
ofImage* loader;
};
However, when quitting oF, I still keep getting a nasty EXC_BAD_ACCESS on the following line:
#235: FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
Inside:
I would think that the destructor takes care of first waiting for the thread to join, then destroying the actual ofImage
; ensuring that the rug isn’t pulled out from under the threaded function? I did this explicitly using a pointer and delete
in the destructor. Does anybody have an idea what’s going wrong?