Skip to content
Permalink
Browse files

[delimitertext] fix watcher check ignored and harmful watcher created…

… for iterator

(fixes #15558)

(cherry-picked from b3e3108)
  • Loading branch information
nirvn authored and nyalldawson committed Sep 14, 2016
1 parent ed75016 commit d5bfc82f7ffc0f38f62b631e5e88b2e29321a2f9
@@ -501,8 +501,16 @@ QgsDelimitedTextFeatureSource::QgsDelimitedTextFeatureSource( const QgsDelimited
, mXyDms( p->mXyDms )
, attributeColumns( p->attributeColumns )
{
QUrl url = p->mFile->url();

// make sure watcher not created when using iterator (e.g. for rendering, see issue #15558)
if ( url.hasQueryItem( "watchFile" ) )
{
url.removeQueryItem( "watchFile" );
}

mFile = new QgsDelimitedTextFile();
mFile->setFromUrl( p->mFile->url() );
mFile->setFromUrl( url );

mExpressionContext << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope();
@@ -35,7 +35,7 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( const QString& url ) :
mEncoding( "UTF-8" ),
mFile( nullptr ),
mStream( nullptr ),
mUseWatcher( true ),
mUseWatcher( false ),
mWatcher( nullptr ),
mDefinitionValid( false ),
mUseHeader( true ),
@@ -158,9 +158,9 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
}

//
if ( url.hasQueryItem( "useWatcher" ) )
if ( url.hasQueryItem( "watchFile" ) )
{
mUseWatcher = ! url.queryItemValue( "useWatcher" ).toUpper().startsWith( 'N' );
mUseWatcher = url.queryItemValue( "watchFile" ).toUpper().startsWith( 'Y' );
}

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

if ( !mUseWatcher )
if ( mUseWatcher )
{
url.addQueryItem( "useWatcher", "no" );
url.addQueryItem( "watchFile", "yes" );
}

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

0 comments on commit d5bfc82

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