Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change undo stack processing order to created-modified-removed #32

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/chainbase/chainbase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ namespace chainbase {

const auto& head = _stack.back();

for( auto id : head.new_ids )
{
_indices.erase( _indices.find( id ) );
}
_next_id = head.old_next_id;

for( auto& item : head.old_values ) {
auto ok = _indices.modify( _indices.find( item.second.id ), [&]( value_type& v ) {
v = std::move( item.second );
});
if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not modify object, most likely a uniqueness constraint was violated" ) );
}

for( auto id : head.new_ids )
{
_indices.erase( _indices.find( id ) );
}
_next_id = head.old_next_id;

for( auto& item : head.removed_values ) {
bool ok = _indices.emplace( std::move( item.second ) ).second;
if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not restore object, most likely a uniqueness constraint was violated" ) );
Expand Down