This patch substitutes by isAttachedToDocument() (almost) everywhere where
getNameInDocument() is used for this purpose.
The very few places not touched by this patch demand a (just a little) less trivial change.
When we change the returning type of getNameInDocument() to std::string,
those places will be easily found, because they shall generate a compiler error
(converting std::string to bool).
Rationale:
The fact that getNameInDocument() return nullptr to indicate
that the object is not attached to a document is responsible for lots of bugs
where the developer does not check for "nullptr".
The idea is to eliminate all those uses of getNameInDocument() and, in the near future,
make getNameInDocument() return always a valid std::string.
Relies on the exception text having been added to the translation database in a previous call to QT_TRANSLATE_NOOP, and put in the 'Exception' context.
Replace the int of the 'resolve' argument of several functions with a proper enum class.
* This avoids the inconsistencies in client code where often true/false is passed when an int is expected
* This avoids the use of magic numbers like 0, 1, 2 or the undocumented 3
It is annoying because error-prone, that on opening e.g. primitives the reference selection mode is always on. You then e.g. click in the model and get a new attachment. But when opening existing primitives you don't always want to change the attachment (often only the parameters). And even if you want to change the attachment, you want to select which one and you like to know when you are in selection mode.
If a body is in a Part container and a new primitive is created no preview is shown because the Part container is automatically made invisiible.
The user has to manually make the container visible but this is an error-prone procedure because the Attachment dialog reacts on user-selection and thus
unintended things can happen. So, this is a serious regression of usability.
The regression is caused by commit a06e0b7c2d but the commit log doesn't explain why the change was even needed.
So, this commit leaves the previous changes but re-adds the old check to filter out container objects.
Rename Python variable 'tv' to avoid potential conflict with others
(PS. I can't reproduce error caused by this. But there is no harm doing
it either).
Handle editing attachment through an App::Link.