Skip to content

Commit

Permalink
Implement move assignment operator for QgsExpressionContext
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 15, 2016
1 parent 786b77a commit 2d191f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/qgsexpressioncontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ QgsExpressionContext::QgsExpressionContext( const QgsExpressionContext& other )
mCachedValues = other.mCachedValues;
}

QgsExpressionContext& QgsExpressionContext::operator=( QgsExpressionContext && other )
{
if ( this != &other )
{
qDeleteAll( mStack );
// move the stack over
mStack = other.mStack;
other.mStack.clear();

mHighlightedVariables = other.mHighlightedVariables;
mCachedValues = other.mCachedValues;
}
return *this;
}

QgsExpressionContext& QgsExpressionContext::operator=( const QgsExpressionContext & other )
{
qDeleteAll( mStack );
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsexpressioncontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class CORE_EXPORT QgsExpressionContext

QgsExpressionContext& operator=( const QgsExpressionContext& other );

QgsExpressionContext& operator=( QgsExpressionContext && other );

~QgsExpressionContext();

/** Check whether a variable is specified by any scope within the context.
Expand Down

1 comment on commit 2d191f6

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 2d191f6 Aug 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that enforce C++11 or be #ifdef'd?

http://stackoverflow.com/a/31010221/2319028

Please sign in to comment.