Skip to content

Commit 9522f31

Browse files
committed
Remove caching from QgsPropertyCollectionStack (too fragile)
1 parent f0f0170 commit 9522f31

File tree

2 files changed

+13
-49
lines changed

2 files changed

+13
-49
lines changed

src/core/qgspropertycollection.cpp

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,7 @@ bool QgsPropertyCollection::readXml( const QDomElement &collectionElem, const QD
322322
//
323323

324324
QgsPropertyCollectionStack::QgsPropertyCollectionStack()
325-
: mDirty( false )
326-
, mHasActiveProperties( false )
327-
, mhasDynamicProperties( false )
328-
{
329-
330-
}
325+
{}
331326

332327
QgsPropertyCollectionStack::~QgsPropertyCollectionStack()
333328
{
@@ -336,17 +331,12 @@ QgsPropertyCollectionStack::~QgsPropertyCollectionStack()
336331

337332
QgsPropertyCollectionStack::QgsPropertyCollectionStack( const QgsPropertyCollectionStack &other )
338333
: QgsAbstractPropertyCollection( other )
339-
, mDirty( false )
340-
, mHasActiveProperties( false )
341-
, mhasDynamicProperties( false )
342334
{
343335
clear();
344336

345337
Q_FOREACH ( QgsPropertyCollection* collection, other.mStack )
346338
{
347339
mStack << new QgsPropertyCollection( *collection );
348-
mHasActiveProperties |= collection->hasActiveProperties();
349-
mhasDynamicProperties |= collection->hasDynamicProperties();
350340
}
351341
}
352342

@@ -358,8 +348,6 @@ QgsPropertyCollectionStack &QgsPropertyCollectionStack::operator=( const QgsProp
358348
Q_FOREACH ( QgsPropertyCollection* collection, other.mStack )
359349
{
360350
mStack << new QgsPropertyCollection( *collection );
361-
mHasActiveProperties |= collection->hasActiveProperties();
362-
mhasDynamicProperties |= collection->hasDynamicProperties();
363351
}
364352

365353
return *this;
@@ -374,20 +362,15 @@ void QgsPropertyCollectionStack::clear()
374362
{
375363
qDeleteAll( mStack );
376364
mStack.clear();
377-
mHasActiveProperties = false;
378-
mhasDynamicProperties = false;
379-
mDirty = false;
380365
}
381366

382367
void QgsPropertyCollectionStack::appendCollection( QgsPropertyCollection* collection )
383368
{
384369
mStack.append( collection );
385-
mDirty = true;
386370
}
387371

388372
QgsPropertyCollection* QgsPropertyCollectionStack::at( int index )
389373
{
390-
mDirty = true;
391374
return mStack.value( index );
392375
}
393376

@@ -398,7 +381,6 @@ const QgsPropertyCollection* QgsPropertyCollectionStack::at( int index ) const
398381

399382
QgsPropertyCollection* QgsPropertyCollectionStack::collection( const QString &name )
400383
{
401-
mDirty = true;
402384
Q_FOREACH ( QgsPropertyCollection* collection, mStack )
403385
{
404386
if ( collection->name() == name )
@@ -409,18 +391,22 @@ QgsPropertyCollection* QgsPropertyCollectionStack::collection( const QString &na
409391

410392
bool QgsPropertyCollectionStack::hasActiveProperties() const
411393
{
412-
if ( mDirty )
413-
rescan();
414-
415-
return mHasActiveProperties;
394+
Q_FOREACH ( const QgsPropertyCollection* collection, mStack )
395+
{
396+
if ( collection->hasActiveProperties() )
397+
return true;
398+
}
399+
return false;
416400
}
417401

418402
bool QgsPropertyCollectionStack::hasDynamicProperties() const
419403
{
420-
if ( mDirty )
421-
rescan();
422-
423-
return mhasDynamicProperties;
404+
Q_FOREACH ( const QgsPropertyCollection* collection, mStack )
405+
{
406+
if ( collection->hasDynamicProperties() )
407+
return true;
408+
}
409+
return false;
424410
}
425411

426412
bool QgsPropertyCollectionStack::isActive( int key ) const
@@ -524,20 +510,5 @@ bool QgsPropertyCollectionStack::readXml( const QDomElement& collectionElem, con
524510
child->readXml( childElem, doc, definitions );
525511
mStack.append( child );
526512
}
527-
mDirty = true;
528513
return true;
529514
}
530-
531-
void QgsPropertyCollectionStack::rescan() const
532-
{
533-
mHasActiveProperties = false;
534-
mhasDynamicProperties = false;
535-
Q_FOREACH ( const QgsPropertyCollection* collection, mStack )
536-
{
537-
mHasActiveProperties |= collection->hasActiveProperties();
538-
mhasDynamicProperties |= collection->hasDynamicProperties();
539-
if ( mHasActiveProperties && mhasDynamicProperties )
540-
break;
541-
}
542-
mDirty = false;
543-
}

src/core/qgspropertycollection.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,6 @@ class CORE_EXPORT QgsPropertyCollectionStack : public QgsAbstractPropertyCollect
439439

440440
QList< QgsPropertyCollection* > mStack;
441441

442-
mutable bool mDirty;
443-
mutable bool mHasActiveProperties;
444-
mutable bool mhasDynamicProperties;
445-
446-
//! Scans through properties and updates cached values
447-
void rescan() const;
448-
449442
};
450443

451444
#endif // QGSPROPERTYCOLLECTION_H

0 commit comments

Comments
 (0)