QgsSipUtils.isPyOwned will return True if an object is owned
by python, or False if ownership is held by another object
or c++ class.
This gives a way to test in advance if we can safely assign
an object to a method which takes ownership (which always results
in a crash).
Deprecate old methods and make methods always take QgsSldExportContext.
Add capacity to QgsSldExportContext to collect export errors and
warnings.
The old API had no way to reliably report errors/warnings during
export to users.
With this new method code, it is now possible to use
`QgsProject::removeMapLayers` with a list of layers or a list of
layers IDs in qt5 and qt6.
Co-authored-by: bdm-oslandia <benoit.de.mezzo@oslandia.com>
Adds an API which an algorithm can implement to support auto-setting
parameter values. This is designed to handle the case
of eg an algorithm which does a file format translation, where
it's desirable to default the output parameter value to an input
parameter value with a different extension.
This can now be done by implementing autogenerateParameterValues
in the algorithm, eg:
def autogenerateParameterValues(self, existingParameters, changedParameter, mode):
if changedParameter == self.INPUT:
input_file = existingParameters.get(self.INPUT)
if input_file:
input_path = Path(input_file)
if input_path.exists():
# auto set output parameter to same as input but with 'qgs' extension
return {self.OUTPUT: input_path.with_suffix('.qgs').as_posix()}
return {}
Works for both toolbox and batch modes for algorithms