Question

I am currently creating a program in Qt, OpenCv, Mac os X. I have a main window, and then a separate window that is opened. I pass the new window several matrix clones in the constructor:

ImageWindow *imageWin = new ImageWindow( 
   cvCloneMat(getData->getMasterRawMat(1)), 
   cvCloneMat(getData->getMasterRawMat(2)), 
   cvCloneMat(getData->getMasterRawMat(3)), 
   cvCloneMat(getData->getMasterRawMat(4)) );
imageWin->show();

How do I deallocate ( where do I call cvReleaseMat ), when the new window is closed?

Was it helpful?

Solution

You can do that in e.g. your closeEvent(). Alternatively, if you use Qt::WA_DeleteOnClose for your widget attributes, the widget will be deleted when it is closed, which means you can place some clean-up routines in the destructor.

OTHER TIPS

Consider using RAII idiom and smart pointers and you won't need to remember when to release allocated memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top