Skip to content

Commit 1d4c606

Browse files
committed
[bugfix] Browser keeps scanning directory with gpkg file
Fixes #17043 by introducing a check for last directory scan timestamp and skipping the directoryChanged signal is the last scan was less than 10 seconds in the past. Tested with > 300 gpkg files in a single directory.
1 parent b26b8d9 commit 1d4c606

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/core/qgsdataitem.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ QVector<QgsDataItem *> QgsDirectoryItem::createChildren()
765765
}
766766

767767
}
768-
768+
mLastScan = QDateTime::currentDateTime();
769769
return children;
770770
}
771771

@@ -794,6 +794,11 @@ void QgsDirectoryItem::setState( State state )
794794

795795
void QgsDirectoryItem::directoryChanged()
796796
{
797+
// If the last scan was less than 10 seconds ago, skip this
798+
if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) < 10000 )
799+
{
800+
return;
801+
}
797802
if ( state() == Populating )
798803
{
799804
// schedule to refresh later, because refresh() simply returns if Populating

src/core/qgsdataitem.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <QString>
2929
#include <QTreeWidget>
3030
#include <QVector>
31+
#include <QDateTime>
3132

3233
#include "qgsmaplayer.h"
3334
#include "qgscoordinatereferencesystem.h"
@@ -487,6 +488,7 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
487488
private:
488489
QFileSystemWatcher *mFileSystemWatcher = nullptr;
489490
bool mRefreshLater;
491+
QDateTime mLastScan;
490492
};
491493

492494
/** \ingroup core

0 commit comments

Comments
 (0)