Skip to content

Commit 2ab58c9

Browse files
committedMar 10, 2019
Rule based labeling RAII
1 parent 34a792f commit 2ab58c9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
 

‎python/core/auto_generated/qgsrulebasedlabeling.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ Constructs the labeling from given tree of rules (takes ownership)
269269
~QgsRuleBasedLabeling();
270270

271271
QgsRuleBasedLabeling::Rule *rootRule();
272+
const Rule *rootRule() const;
272273

273274
static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
274275
%Docstring

‎src/core/qgsrulebasedlabeling.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,16 @@ QgsRuleBasedLabeling *QgsRuleBasedLabeling::clone() const
411411

412412
QgsRuleBasedLabeling::~QgsRuleBasedLabeling()
413413
{
414-
delete mRootRule;
414+
}
415+
416+
QgsRuleBasedLabeling::Rule *QgsRuleBasedLabeling::rootRule()
417+
{
418+
return mRootRule.get();
419+
}
420+
421+
const QgsRuleBasedLabeling::Rule *QgsRuleBasedLabeling::rootRule() const SIP_SKIP
422+
{
423+
return mRootRule.get();
415424
}
416425

417426

‎src/core/qgsrulebasedlabeling.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling
346346
explicit QgsRuleBasedLabeling( QgsRuleBasedLabeling::Rule *root SIP_TRANSFER );
347347
~QgsRuleBasedLabeling() override;
348348

349-
QgsRuleBasedLabeling::Rule *rootRule() { return mRootRule; }
350-
const Rule *rootRule() const SIP_SKIP { return mRootRule; }
349+
QgsRuleBasedLabeling::Rule *rootRule();
350+
const Rule *rootRule() const;
351351

352352
//! Create the instance from a DOM element with saved configuration
353353
static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
@@ -375,7 +375,7 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling
375375
void toSld( QDomNode &parent, const QgsStringMap &props ) const override;
376376

377377
protected:
378-
Rule *mRootRule = nullptr;
378+
std::unique_ptr<Rule> mRootRule;
379379
};
380380

381381
#ifndef SIP_RUN

0 commit comments

Comments
 (0)
Please sign in to comment.