There are still issues with all kind of projectData with it's QObject::parenting, so we can't ensure that all of that data is deleted correctly when the file is closed but also the application crashes sometimes when stuff is deleted, which is still necessary.
This is a huge problem, especially when it comes to larger projects and bigger amount of data.
We use the QObject's parenting and object hierarchy system to control when an object should be deleted.
But the problem is: new Objects are created all over the entire application and it's not possible to ensure that all objects always get the correct parent.
To fix this issue and improve the code I suggest:
move all "generatings" of objects to a central place in the code:
every projectDataItem that can or should own other projectDataItems gets a special "new"-Functions which generates a new child, sets is as a child, adds it and returns it. For example (in Line class):
Route *newRoute(const Route &newRoute) {
// create new Route object by copying the given one
Route *r = new Route(newRoute);
// set parent
r->setParent(this);
// add to "myself"
addRoute(r);
// return for further modification if necessary
return r;
}
From everywhere when a new object is needed it can use this new function. With that we can ensure that every object gets the right parent and (!) lives in the right thread (which is a problem with the PlgOmsiImporter for example).
There are still issues with all kind of projectData with it's QObject::parenting, so we can't ensure that all of that data is deleted correctly when the file is closed but also the application crashes sometimes when stuff is deleted, which is still necessary. This is a huge problem, especially when it comes to larger projects and bigger amount of data. We use the QObject's parenting and object hierarchy system to control when an object should be deleted. But the problem is: new Objects are created all over the entire application and it's not possible to ensure that all objects always get the correct parent. To fix this issue and improve the code I suggest:
From everywhere when a new object is needed it can use this new function. With that we can ensure that every object gets the right parent and (!) lives in the right thread (which is a problem with the PlgOmsiImporter for example).