Skip to content
Permalink
Browse files

The model "last used parameter values" setting should live outside

the undo stack

We don't want to roll these back if users are undo/redoing changes
  • Loading branch information
nyalldawson committed Mar 9, 2020
1 parent e7b5c26 commit c4df4dc8f7c3f8ad8da44528bd6dec71ea2e44a9
Showing with 21 additions and 0 deletions.
  1. +12 −0 src/gui/processing/models/qgsmodelundocommand.cpp
  2. +9 −0 tests/src/gui/testprocessinggui.cpp
@@ -39,7 +39,13 @@ int QgsModelUndoCommand::id() const
void QgsModelUndoCommand::undo()
{
QUndoCommand::undo();

// some settings must live "outside" the undo stack
const QVariantMap params = mModel->designerParameterValues();

mModel->loadVariant( mBeforeState );

mModel->setDesignerParameterValues( params );
}

void QgsModelUndoCommand::redo()
@@ -50,7 +56,13 @@ void QgsModelUndoCommand::redo()
return;
}
QUndoCommand::redo();

// some settings must live "outside" the undo stack
const QVariantMap params = mModel->designerParameterValues();

mModel->loadVariant( mAfterState );

mModel->setDesignerParameterValues( params );
}

bool QgsModelUndoCommand::mergeWith( const QUndoCommand *other )
@@ -318,6 +318,15 @@ void TestProcessingGui::testModelUndo()
QCOMPARE( model.childAlgorithm( QStringLiteral( "alg1" ) ).description(), QStringLiteral( "alg1" ) );
command.redo();
QCOMPARE( model.childAlgorithm( QStringLiteral( "alg1" ) ).description(), QStringLiteral( "new desc" ) );

// the last used parameter values setting should not be affected by undo stack changes
QVariantMap params;
params.insert( QStringLiteral( "a" ), 1 );
model.setDesignerParameterValues( params );
command.undo();
QCOMPARE( model.designerParameterValues(), params );
command.redo();
QCOMPARE( model.designerParameterValues(), params );
}

void TestProcessingGui::testSetGetConfig()

0 comments on commit c4df4dc

Please sign in to comment.
You can’t perform that action at this time.