Skip to content
Permalink
Browse files

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

… for iterator

(fixes #15558)
  • Loading branch information
nirvn committed Sep 13, 2016
1 parent f55d7d3 commit b3e31087181732f7511d047b98352e97f08b0d04
@@ -500,8 +500,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 b3e3108

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