Skip to content

Commit

Permalink
[delimitertext] fix watcher check ignored and harmful watcher created…
Browse files Browse the repository at this point in the history
… for iterator

(fixes #15558)

(cherry-picked from b3e3108)
  • Loading branch information
nirvn authored and nyalldawson committed Sep 14, 2016
1 parent fc17b3e commit e4ec4e3
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
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,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
Original file line number Diff line number Diff line change
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 e4ec4e3

Please sign in to comment.