Rule based labeling RAII

This commit is contained in:
Matthias Kuhn 2019-03-10 16:22:21 +01:00
parent 34a792ffdc
commit 2ab58c94db
No known key found for this signature in database
GPG Key ID: 7A7F1A1C90C3E6A7
3 changed files with 14 additions and 4 deletions

View File

@ -269,6 +269,7 @@ Constructs the labeling from given tree of rules (takes ownership)
~QgsRuleBasedLabeling();
QgsRuleBasedLabeling::Rule *rootRule();
const Rule *rootRule() const;
static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
%Docstring

View File

@ -411,7 +411,16 @@ QgsRuleBasedLabeling *QgsRuleBasedLabeling::clone() const
QgsRuleBasedLabeling::~QgsRuleBasedLabeling()
{
delete mRootRule;
}
QgsRuleBasedLabeling::Rule *QgsRuleBasedLabeling::rootRule()
{
return mRootRule.get();
}
const QgsRuleBasedLabeling::Rule *QgsRuleBasedLabeling::rootRule() const SIP_SKIP
{
return mRootRule.get();
}

View File

@ -346,8 +346,8 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling
explicit QgsRuleBasedLabeling( QgsRuleBasedLabeling::Rule *root SIP_TRANSFER );
~QgsRuleBasedLabeling() override;
QgsRuleBasedLabeling::Rule *rootRule() { return mRootRule; }
const Rule *rootRule() const SIP_SKIP { return mRootRule; }
QgsRuleBasedLabeling::Rule *rootRule();
const Rule *rootRule() const;
//! Create the instance from a DOM element with saved configuration
static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
@ -375,7 +375,7 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling
void toSld( QDomNode &parent, const QgsStringMap &props ) const override;
protected:
Rule *mRootRule = nullptr;
std::unique_ptr<Rule> mRootRule;
};
#ifndef SIP_RUN