Skip to content

Commit

Permalink
Merge pull request #3483 from nirvn/fix_delimited_text_file
Browse files Browse the repository at this point in the history
[delimitertext] fix watcher check ignored and harmful watcher created for iterator (fixes #15558)

@nirvn Many thanks for fixing this
  • Loading branch information
ccrook committed Sep 13, 2016
2 parents 717e716 + b3e3108 commit 92ed3be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit 92ed3be

Please sign in to comment.