I inherited a program that was initiated by command-line and I have to turn it into a project-based program, where you have a Open project on the menu and so on.
I've moved everything from the QMainWindow constructor to a loadProject function.
Now the problem arises when the user loads a project when there was already one opened. The items allocated in the heap by the mainwindow will be reasigned and therefore we have a memory leak. I can take care of the project data, but I have many graphic items allocated in the heap with a hierarchy of centralWidget->layout->scene->items and centralWidget->layout->items
I've thought I can delete the central widget so I get rid of everything, but it's an autogenerated object located in ui_mainwindow.h. How can I reset it or rebuild it so I can assign it again once I delete it? Does anything I say make sense? Any other better approaches?
Bookmarks