Open NelDav opened 3 months ago
According to the Qt Documentation, the QObject::destroyed
signal is emmitted just before the object is destructed. I see no reason, why it should be triggered when the object changes.
I cannot see any differences in QObject::destroyed
and the new signal. Can you please explain it a bit more?
Imagine a project that contains a PreDesign package. The PreDesign package contains a turbine. Assume, the user can remove the turbine via the context menu and in this case, we want to execute some code.
The turbine object is not only deleted in case the user removes the object from the PreDesign package but also if the Project is closed. Meaning, that the destroyed
signal is also triggered in both cases. But in the second case, the object is not removed from the project.
So you mean explicitly the removal of a gtobject from the project tree? Currently, there is no way to tell, whether a object was deleted or removed from a project though.
We'll discuss this with the colleagues.
I'd like to have a good use case for the feature. Just executing "some code" is not specific enough.
What kind of code should be executed? Why?
As you see in the description, the original feature request is very old. Back then, the PrEDiCT Datamodell was not a GTlab Datamodell. Instead the PrEDiCT data object was just a reference to a PrEDiCT-input-file. The feature was needed to remove the input file in case somebody removed the PrEDiCT object from the project. Since PrEDiCT implements the GTlab datamodell, this is no longer needed. However, as soon as you have to keep track of data outside of GTlab, this signal will help to clean up this data.
The presented use-case might be implemented with UI-classes for the relevant objects to do more specific work. The UI class could implement e.g a specific "unlink" function to remove the file behind the datamodel object when it is deleted.
As long as the data is only deleted via the UI item, the solution via UI item will be sufficient. But what if the object is deleted without using the UI item. For example by a calculator.
Summary
From https://gitlab.dlr.de/gtlab/gtlab-issuetracking/-/issues/14
You might execute some code in case a GtObject is removed from the project. I therefore suggest to implement a signal in
GtObject
, that is called if the object is removed from the project. Probably this is something else than theQObject::destroyed
becauseQObject::destroyed
will also be called if the user just changes or closes the project.Improvements
We can execute code in case a
GtObject
is removed from the project.Drawbacks
QObject::destroyed
.Current workarounds
No response