mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-12 00:06:43 -04:00
use a pointer otherwise Python is creating a copy
This commit is contained in:
parent
0ec7d54c9c
commit
4e2eb0eb9c
@ -210,6 +210,8 @@ class edit(object):
|
||||
self.layer.rollBack()
|
||||
return False
|
||||
|
||||
# Python class to mimic QgsReadWriteContextCategoryPopper C++ class
|
||||
|
||||
|
||||
class ReadWriteContextEnterCategory():
|
||||
def __init__(self, context, category_name, details=None):
|
||||
@ -227,6 +229,7 @@ class ReadWriteContextEnterCategory():
|
||||
return True
|
||||
|
||||
|
||||
# Inject the context manager into QgsReadWriteContext class as a member
|
||||
QgsReadWriteContext.enterCategory = ReadWriteContextEnterCategory
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -122,10 +122,14 @@ class CORE_EXPORT QgsReadWriteContextCategoryPopper
|
||||
{
|
||||
public:
|
||||
//! Creates a popper
|
||||
QgsReadWriteContextCategoryPopper( QgsReadWriteContext &context ) : mContext( context ) {}
|
||||
~QgsReadWriteContextCategoryPopper() {mContext.leaveCategory();}
|
||||
QgsReadWriteContextCategoryPopper( QgsReadWriteContext *context ) : mContext( context ) {}
|
||||
~QgsReadWriteContextCategoryPopper()
|
||||
{
|
||||
if ( mContext )
|
||||
mContext->leaveCategory();
|
||||
}
|
||||
private:
|
||||
QgsReadWriteContext mContext;
|
||||
QgsReadWriteContext *mContext;
|
||||
};
|
||||
|
||||
#endif // QGSREADWRITECONTEXT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user