mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Setting a property to null in collections removes property
This commit is contained in:
parent
5e9f6ac5cc
commit
c23de083ce
@ -630,7 +630,8 @@ class QgsPropertyCollection
|
||||
* @param key integer key for property. Any existing property with the same key will be deleted
|
||||
* and replaced by this property. The intended use case is that a context specific enum is cast to
|
||||
* int and used for the key value.
|
||||
* @param property property to add. Ownership is transferred to the collection.
|
||||
* @param property property to add. Ownership is transferred to the collection. Setting a property
|
||||
* to null will remove the property from the collection.
|
||||
*/
|
||||
void setProperty( int key, QgsAbstractProperty* property /Transfer/ );
|
||||
|
||||
|
@ -724,7 +724,9 @@ void QgsPropertyCollection::setProperty( int key, QgsAbstractProperty* property
|
||||
if ( hasProperty( key ) )
|
||||
delete mProperties.take( key );
|
||||
|
||||
mProperties.insert( key, property );
|
||||
if ( property )
|
||||
mProperties.insert( key, property );
|
||||
|
||||
mDirty = true;
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,8 @@ class CORE_EXPORT QgsPropertyCollection
|
||||
* @param key integer key for property. Any existing property with the same key will be deleted
|
||||
* and replaced by this property. The intended use case is that a context specific enum is cast to
|
||||
* int and used for the key value.
|
||||
* @param property property to add. Ownership is transferred to the collection.
|
||||
* @param property property to add. Ownership is transferred to the collection. Setting a property
|
||||
* to null will remove the property from the collection.
|
||||
*/
|
||||
void setProperty( int key, QgsAbstractProperty* property );
|
||||
|
||||
|
@ -797,6 +797,12 @@ void TestQgsProperty::propertyCollection()
|
||||
QCOMPARE( collection.count(), 2 );
|
||||
QCOMPARE( collection.propertyKeys().toSet(), QSet<int>() << Property1 << Property3 );
|
||||
|
||||
//test removing a property
|
||||
collection.setProperty( Property1, nullptr );
|
||||
QVERIFY( !collection.property( Property1 ) );
|
||||
QVERIFY( !collection.hasProperty( Property1 ) );
|
||||
QCOMPARE( collection.propertyKeys(), QList<int>() << Property3 );
|
||||
|
||||
//clear
|
||||
collection.clear();
|
||||
QCOMPARE( collection.count(), 0 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user