Skip to content

Commit

Permalink
Fix redoing group visibility creates multiple new undo commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 9, 2017
1 parent 30eab10 commit fdc0f75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/layout/qgslayoutitemgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ void QgsLayoutItemGroup::setVisibility( const bool visible )
{
if ( !item )
continue;
bool prev = item->mBlockUndoCommands;
item->mBlockUndoCommands = mBlockUndoCommands;
item->setVisibility( visible );
item->mBlockUndoCommands = prev;
}
//lastly set visibility for group item itself
QgsLayoutItem::setVisibility( visible );

if ( !shouldBlockUndoCommands() )
mLayout->undoStack()->endMacro();
}
Expand Down
17 changes: 17 additions & 0 deletions tests/src/core/testqgslayoutitemgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,23 @@ void TestQgsLayoutItemGroup::groupVisibility()
QVERIFY( item->isVisible() );
QVERIFY( item2->isVisible() );
QVERIFY( group->isVisible() );

l.undoStack()->stack()->undo();
QVERIFY( !item->isVisible() );
QVERIFY( !item2->isVisible() );
QVERIFY( !group->isVisible() );
l.undoStack()->stack()->undo();
QVERIFY( item->isVisible() );
QVERIFY( item2->isVisible() );
QVERIFY( group->isVisible() );
l.undoStack()->stack()->redo();
QVERIFY( !item->isVisible() );
QVERIFY( !item2->isVisible() );
QVERIFY( !group->isVisible() );
l.undoStack()->stack()->redo();
QVERIFY( item->isVisible() );
QVERIFY( item2->isVisible() );
QVERIFY( group->isVisible() );
}

void TestQgsLayoutItemGroup::moveGroup()
Expand Down

0 comments on commit fdc0f75

Please sign in to comment.