Skip to content

Commit

Permalink
[bugfix] Browser keeps scanning directory with gpkg file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elpaso committed Sep 12, 2017
1 parent b26b8d9 commit 1d4c606
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/qgsdataitem.cpp
Expand Up @@ -765,7 +765,7 @@ QVector<QgsDataItem *> QgsDirectoryItem::createChildren()
}

}

mLastScan = QDateTime::currentDateTime();
return children;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.h
Expand Up @@ -28,6 +28,7 @@
#include <QString>
#include <QTreeWidget>
#include <QVector>
#include <QDateTime>

#include "qgsmaplayer.h"
#include "qgscoordinatereferencesystem.h"
Expand Down Expand Up @@ -487,6 +488,7 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
private:
QFileSystemWatcher *mFileSystemWatcher = nullptr;
bool mRefreshLater;
QDateTime mLastScan;
};

/** \ingroup core
Expand Down

0 comments on commit 1d4c606

Please sign in to comment.