When removing a printer, the files in %appdata%/cura/<version>/
/definition_changes/ remained intact. This commit fixes that by
making sure that the definitionChanges are removed before removing
the machine.
This was originally added for backwards compatibility with old versions of Uranium. However the link between Cura versions and Uranium versions is already very strong (Cura crashes with old Uranium versions) so this is not necessary.
It was also adding warnings in our log that these extruders had already been added to the printer.
Done during Turbo Testing and Tooling, to clean up our log files.
When switching printers, it would first emit the global container changed signal which connects to _onGlobalContainerChanged, then update stuff in the extruder manager, then manually call _onGlobalContainerChanged again to update some other stuff with the new data from the extruder manager. This was prohibitively expensive, so this prevents that.
Another double or triple emit of the activeExtruderChanged was removed in the extruder manager when creating the extruders for a printer: It would first set the extruder number to 0, possibly emitting the signal, then emit the signal just to be sure since the extruder itself changed (rather than just the number), and then change the extruder number to the preferred extruder, possibly again emitting a signal. Now it just sets the extruder number to the preferred extruder and always emits the signal once (either through setting the extruder number or manually afterwards).
Contributes to issue CURA-6793.
The extruders are added when changing printers anyway, and we call this change signal upon start-up. So one of them is going to do unnecessary work.
Contributes to issue CURA-6793.
This reverts commit 85f10e7c4f9bc48afd2fe43903e565b128e03189.
The second time you start Cura, it won't slice due to the number of extruders being wrong.
We know in these places that there must be a global stack at this point. So to hide the type error we'll cast it here.
Of course, the danger in this is that someone might call this function that doesn't know about this requirement and calls it when there is potentially no global stack yet. Hopefully they'll discover this crash when that happens then.