I’m dealing with a large image and am doing several different processes on the QImage. Based on my research, I believe QSharedPointer is the correct answer. Is this correct? Because the image is so large, I don’t want do copies of it and I want it to stay alive until all the processes are done. However when it is finished and is no longer needed, I want to release the memory. While trying to implement it, it crashes between processes…this leads me to believe the pointer is getting deleted before I want it to. Are there any good examples on using QSharedPointer or are there better ways of doing the same thing?
I’m probably getting wrapped around the axle by misreading/misinterpreting the documentation.
void mainImgFunction()
{
QSharedPointer<QImage> img(new QImage("c:/bigImg.png"));
*img = process1(*img);
*img = process2(*img);//it crashes here
}
QImage process1(QImage img)
{
/*do the processing*/
return img;
}
QImage process2(QImage img)
{
/*do the processing*/
return img;
}
↧