Skip to content

Commit 92ed3be

Browse files
authored
Merge pull request #3483 from nirvn/fix_delimited_text_file
[delimitertext] fix watcher check ignored and harmful watcher created for iterator (fixes #15558) @nirvn Many thanks for fixing this
2 parents 717e716 + b3e3108 commit 92ed3be

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,16 @@ QgsDelimitedTextFeatureSource::QgsDelimitedTextFeatureSource( const QgsDelimited
500500
, mXyDms( p->mXyDms )
501501
, attributeColumns( p->attributeColumns )
502502
{
503+
QUrl url = p->mFile->url();
504+
505+
// make sure watcher not created when using iterator (e.g. for rendering, see issue #15558)
506+
if ( url.hasQueryItem( "watchFile" ) )
507+
{
508+
url.removeQueryItem( "watchFile" );
509+
}
510+
503511
mFile = new QgsDelimitedTextFile();
504-
mFile->setFromUrl( p->mFile->url() );
512+
mFile->setFromUrl( url );
505513

506514
mExpressionContext << QgsExpressionContextUtils::globalScope()
507515
<< QgsExpressionContextUtils::projectScope();

src/providers/delimitedtext/qgsdelimitedtextfile.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( const QString& url )
3535
, mEncoding( "UTF-8" )
3636
, mFile( nullptr )
3737
, mStream( nullptr )
38-
, mUseWatcher( true )
38+
, mUseWatcher( false )
3939
, mWatcher( nullptr )
4040
, mDefinitionValid( false )
4141
, mUseHeader( true )
@@ -158,9 +158,9 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
158158
}
159159

160160
//
161-
if ( url.hasQueryItem( "useWatcher" ) )
161+
if ( url.hasQueryItem( "watchFile" ) )
162162
{
163-
mUseWatcher = ! url.queryItemValue( "useWatcher" ).toUpper().startsWith( 'N' );
163+
mUseWatcher = url.queryItemValue( "watchFile" ).toUpper().startsWith( 'Y' );
164164
}
165165

166166
// The default type is csv, to be consistent with the
@@ -269,9 +269,9 @@ QUrl QgsDelimitedTextFile::url()
269269
url.addQueryItem( "encoding", mEncoding );
270270
}
271271

272-
if ( !mUseWatcher )
272+
if ( mUseWatcher )
273273
{
274-
url.addQueryItem( "useWatcher", "no" );
274+
url.addQueryItem( "watchFile", "yes" );
275275
}
276276

277277
url.addQueryItem( "type", type() );

0 commit comments

Comments
 (0)