Skip to content

Commit 2d191f6

Browse files
committedAug 15, 2016
Implement move assignment operator for QgsExpressionContext
1 parent 786b77a commit 2d191f6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎src/core/qgsexpressioncontext.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ QgsExpressionContext::QgsExpressionContext( const QgsExpressionContext& other )
217217
mCachedValues = other.mCachedValues;
218218
}
219219

220+
QgsExpressionContext& QgsExpressionContext::operator=( QgsExpressionContext && other )
221+
{
222+
if ( this != &other )
223+
{
224+
qDeleteAll( mStack );
225+
// move the stack over
226+
mStack = other.mStack;
227+
other.mStack.clear();
228+
229+
mHighlightedVariables = other.mHighlightedVariables;
230+
mCachedValues = other.mCachedValues;
231+
}
232+
return *this;
233+
}
234+
220235
QgsExpressionContext& QgsExpressionContext::operator=( const QgsExpressionContext & other )
221236
{
222237
qDeleteAll( mStack );

‎src/core/qgsexpressioncontext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ class CORE_EXPORT QgsExpressionContext
259259

260260
QgsExpressionContext& operator=( const QgsExpressionContext& other );
261261

262+
QgsExpressionContext& operator=( QgsExpressionContext && other );
263+
262264
~QgsExpressionContext();
263265

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

1 commit comments

Comments
 (1)

m-kuhn commented on Aug 29, 2016

@m-kuhn
Member

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

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

Please sign in to comment.