From a483ef817aba799c02a444fe5cf21857f47b6246 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Wed, 28 Feb 2018 20:32:51 -0400 Subject: [PATCH] correctly use reference for context in QgsReadWriteContextCategoryPopper --- python/core/qgsreadwritecontext.sip.in | 2 +- src/core/qgsreadwritecontext.cpp | 2 +- src/core/qgsreadwritecontext.h | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/python/core/qgsreadwritecontext.sip.in b/python/core/qgsreadwritecontext.sip.in index 34bed2238e3..e9d851195e2 100644 --- a/python/core/qgsreadwritecontext.sip.in +++ b/python/core/qgsreadwritecontext.sip.in @@ -116,7 +116,7 @@ This would happen when it gets out of scope. #include "qgsreadwritecontext.h" %End public: - QgsReadWriteContextCategoryPopper( QgsReadWriteContext *context ); + QgsReadWriteContextCategoryPopper( QgsReadWriteContext &context ); %Docstring Creates a popper %End diff --git a/src/core/qgsreadwritecontext.cpp b/src/core/qgsreadwritecontext.cpp index cdda338a065..4baa772c16e 100644 --- a/src/core/qgsreadwritecontext.cpp +++ b/src/core/qgsreadwritecontext.cpp @@ -41,7 +41,7 @@ QgsReadWriteContextCategoryPopper QgsReadWriteContext::enterCategory( const QStr if ( !details.isEmpty() ) message.append( QString( " :: %1" ).arg( details ) ); mCategories.push_back( message ); - return QgsReadWriteContextCategoryPopper( this ); + return QgsReadWriteContextCategoryPopper( *this ); } void QgsReadWriteContext::leaveCategory() diff --git a/src/core/qgsreadwritecontext.h b/src/core/qgsreadwritecontext.h index abd3b79743b..7e20caf14b5 100644 --- a/src/core/qgsreadwritecontext.h +++ b/src/core/qgsreadwritecontext.h @@ -124,14 +124,10 @@ class CORE_EXPORT QgsReadWriteContextCategoryPopper { public: //! Creates a popper - QgsReadWriteContextCategoryPopper( QgsReadWriteContext *context ) : mContext( context ) {} - ~QgsReadWriteContextCategoryPopper() - { - if ( mContext ) - mContext->leaveCategory(); - } + QgsReadWriteContextCategoryPopper( QgsReadWriteContext &context ) : mContext( context ) {} + ~QgsReadWriteContextCategoryPopper() {mContext.leaveCategory();} private: - QgsReadWriteContext *mContext; + QgsReadWriteContext &mContext; }; #endif // QGSREADWRITECONTEXT_H