Skip to content
Permalink
Browse files

[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.
  • Loading branch information
elpaso committed Sep 9, 2017
1 parent b26b8d9 commit 1d4c6061a8a5512092041aafea14a8a32247d046
Showing with 8 additions and 1 deletion.
  1. +6 −1 src/core/qgsdataitem.cpp
  2. +2 −0 src/core/qgsdataitem.h
@@ -765,7 +765,7 @@ QVector<QgsDataItem *> 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
@@ -28,6 +28,7 @@
#include <QString>
#include <QTreeWidget>
#include <QVector>
#include <QDateTime>

#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

0 comments on commit 1d4c606

Please sign in to comment.
You can’t perform that action at this time.