Skip to content

Commit 03e40f7

Browse files
committed
[processing] Remove all remaining algorithm copies
Algorithms are no longer copied - just a single const instance of each algorithm is used
1 parent 8b4bf88 commit 03e40f7

19 files changed

+18
-94
lines changed

python/core/processing/qgsprocessingalgorithm.sip

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ class QgsProcessingAlgorithm
110110
:rtype: QgsProcessingProvider
111111
%End
112112

113-
void setProvider( QgsProcessingProvider *provider );
114-
115113
QgsProcessingParameterDefinitions parameterDefinitions() const;
116114
%Docstring
117115
Returns an ordered list of parameter definitions utilized by the algorithm.

python/plugins/processing/algs/gdal/GdalAlgorithm.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ def shortHelp(self):
9292
'''.format(self.commandName(), url))
9393

9494
def commandName(self):
95-
alg = self.getCopy()
96-
for output in alg.outputs:
95+
for output in self.outputs:
9796
output.setValue("dummy")
98-
for param in alg.parameters:
97+
for param in self.parameters:
9998
param.setValue("1")
100-
name = alg.getConsoleCommands()[0]
99+
name = self.getConsoleCommands()[0]
101100
if name.endswith(".py"):
102101
name = name[:-3]
103102
return name

python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ def __init__(self, descriptionfile):
9797
except ImportError:
9898
self.module = None
9999

100-
def getCopy(self):
101-
return self
102-
103100
def name(self):
104101
return self._name
105102

python/plugins/processing/algs/saga/SagaAlgorithm.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ def __init__(self, descriptionfile):
7878
self._display_name = ''
7979
self._group = ''
8080

81-
def getCopy(self):
82-
return self
83-
8481
def icon(self):
8582
if self._icon is None:
8683
self._icon = QIcon(os.path.join(pluginPath, 'images', 'saga.png'))

python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ def __init__(self):
7474

7575
self.defineCharacteristics()
7676

77-
def getCopy(self):
78-
"""Returns a new instance of this algorithm, ready to be used
79-
for being executed.
80-
"""
81-
newone = self
82-
newone.parameters = copy.deepcopy(self.parameters)
83-
newone.outputs = copy.deepcopy(self.outputs)
84-
return newone
85-
8677
# methods to overwrite when creating a custom geoalgorithm
8778

8879
def _formatHelp(self, text):

python/plugins/processing/core/Processing.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
130130
QgsMessageLog.logMessage(Processing.tr('Error: Algorithm {0} not found\n').format(algOrName),
131131
Processing.tr("Processing"))
132132
return
133-
# hack - remove when getCopy is removed
134-
provider = alg.provider()
135-
alg = alg.getCopy()
136-
#hack pt2
137-
alg.setProvider(provider)
138133

139134
if len(args) == 1 and isinstance(args[0], dict):
140135
# Set params by name and try to run the alg even if not all parameter values are provided,

python/plugins/processing/gui/BatchAlgorithmDialog.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def accept(self):
7272
self.canceled = False
7373

7474
for row in range(self.mainWidget.tblParameters.rowCount()):
75-
alg = self.alg.getCopy()
76-
# hack - remove when getCopy is removed
77-
alg.setProvider(self.alg.provider())
75+
alg = self.alg
7876
col = 0
7977
for param in alg.parameters:
8078
if param.hidden:

python/plugins/processing/gui/BatchPanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def save(self):
182182
algParams = {}
183183
algOutputs = {}
184184
col = 0
185-
alg = self.alg.getCopy()
185+
alg = self.alg
186186
for param in alg.parameters:
187187
if param.hidden:
188188
continue

python/plugins/processing/gui/EditRenderingStylesDialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, alg):
4848
super(EditRenderingStylesDialog, self).__init__(None)
4949
self.setupUi(self)
5050

51-
self.alg = alg.getCopy()
51+
self.alg = alg
5252

5353
self.tblStyles.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
5454
self.setWindowTitle(self.alg.displayName())

python/plugins/processing/gui/ProcessingToolbox.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ def executeAlgorithmAsBatchProcess(self):
246246
item = self.algorithmTree.currentItem()
247247
if isinstance(item, TreeAlgorithmItem):
248248
alg = QgsApplication.processingRegistry().algorithmById(item.alg.id())
249-
#hack - remove when getCopy is removed
250-
provider = alg.provider()
251-
alg = alg.getCopy()
252-
#hack pt 2
253-
alg.setProvider(provider)
254249
dlg = BatchAlgorithmDialog(alg)
255250
dlg.show()
256251
dlg.exec_()
@@ -270,11 +265,6 @@ def executeAlgorithm(self):
270265
dlg.exec_()
271266
return
272267

273-
# temporary hack - TODO remove this getCopy when parameters are moved from algorithm
274-
provider = alg.provider()
275-
alg = alg.getCopy()
276-
alg.setProvider(provider)
277-
278268
if (alg.countVisibleParameters() + alg.getVisibleOutputsCount()) > 0:
279269
dlg = alg.getCustomParametersDialog()
280270
if not dlg:

0 commit comments

Comments
 (0)