Skip to content

Commit

Permalink
The model "last used parameter values" setting should live outside
Browse files Browse the repository at this point in the history
the undo stack

We don't want to roll these back if users are undo/redoing changes
  • Loading branch information
nyalldawson committed Mar 10, 2020
1 parent e7b5c26 commit c4df4dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gui/processing/models/qgsmodelundocommand.cpp
Expand Up @@ -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()
Expand All @@ -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 )
Expand Down
9 changes: 9 additions & 0 deletions tests/src/gui/testprocessinggui.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit c4df4dc

Please sign in to comment.