Skip to content

Commit

Permalink
[processing] Fix crashes when running algs in "in place" mode
Browse files Browse the repository at this point in the history
Fixes #35844
  • Loading branch information
nyalldawson committed Apr 20, 2020
1 parent 003ab16 commit 60f40f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -58,7 +58,7 @@ def __init__(self, alg, in_place=False, parent=None):

self.feedback_dialog = None
self.in_place = in_place
self.active_layer = None
self.active_layer = iface.activeLayer() if self.in_place else None

self.context = None
self.feedback = None
Expand All @@ -72,7 +72,6 @@ def __init__(self, alg, in_place=False, parent=None):
self.buttonBox().addButton(self.runAsBatchButton,
QDialogButtonBox.ResetRole) # reset role to ensure left alignment
else:
self.active_layer = iface.activeLayer()
self.runAsBatchButton = None
has_selection = self.active_layer and (self.active_layer.selectedFeatureCount() > 0)
self.buttonBox().button(QDialogButtonBox.Ok).setText(
Expand All @@ -86,6 +85,7 @@ def __init__(self, alg, in_place=False, parent=None):

def getParametersPanel(self, alg, parent):
panel = ParametersPanel(parent, alg, self.in_place)
panel.active_layer = self.active_layer
return panel

def runAsBatch(self):
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/gui/ParametersPanel.py
Expand Up @@ -48,6 +48,7 @@ class ParametersPanel(QgsProcessingParametersWidget):
def __init__(self, parent, alg, in_place=False):
super().__init__(alg, parent)
self.in_place = in_place
self.active_layer = None

self.wrappers = {}

Expand Down
5 changes: 3 additions & 2 deletions src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
Expand Up @@ -5399,12 +5399,13 @@ void QgsProcessingMapLayerWidgetWrapper::setWidgetContext( const QgsProcessingPa

void QgsProcessingMapLayerWidgetWrapper::setWidgetValue( const QVariant &value, QgsProcessingContext &context )
{
mComboBox->setValue( value, context );
if ( mComboBox )
mComboBox->setValue( value, context );
}

QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue() const
{
return mComboBox->value();
return mComboBox ? mComboBox->value() : QVariant();
}

QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes() const
Expand Down
2 changes: 1 addition & 1 deletion src/gui/processing/qgsprocessingwidgetwrapperimpl.h
Expand Up @@ -1671,7 +1671,7 @@ class GUI_EXPORT QgsProcessingMapLayerWidgetWrapper : public QgsAbstractProcessi

private:

QgsProcessingMapLayerComboBox *mComboBox = nullptr;
QPointer< QgsProcessingMapLayerComboBox > mComboBox;
int mBlockSignals = 0;

friend class TestProcessingGui;
Expand Down

0 comments on commit 60f40f0

Please sign in to comment.