diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index ebc5f545dec6..9dbba3599e6e 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -765,7 +765,7 @@ QVector QgsDirectoryItem::createChildren() } } - + mLastScan = QDateTime::currentDateTime(); return children; } @@ -794,6 +794,11 @@ void QgsDirectoryItem::setState( State state ) void QgsDirectoryItem::directoryChanged() { + // If the last scan was less than 10 seconds ago, skip this + if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) < 10000 ) + { + return; + } if ( state() == Populating ) { // schedule to refresh later, because refresh() simply returns if Populating diff --git a/src/core/qgsdataitem.h b/src/core/qgsdataitem.h index 969740e71812..94cc92df1bb6 100644 --- a/src/core/qgsdataitem.h +++ b/src/core/qgsdataitem.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "qgsmaplayer.h" #include "qgscoordinatereferencesystem.h" @@ -487,6 +488,7 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem private: QFileSystemWatcher *mFileSystemWatcher = nullptr; bool mRefreshLater; + QDateTime mLastScan; }; /** \ingroup core