Reputation: 864
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?
Upvotes: 1
Views: 3148
Reputation: 13238
Consider using RAII idiom and smart pointers and you won't need to remember when to release allocated memory.
Upvotes: 1
Reputation: 12561
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.
Upvotes: 8