Skip to content

Commit b3879cf

Browse files
committedJul 24, 2018
Modernize code
(cherry-picked from 409d47e)
1 parent a1f8efa commit b3879cf

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed
 

‎src/providers/wfs/qgswfsrequest.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
7878
QString modifiedUrlString = modifiedUrl.toString();
7979
// Qt5 does URL encoding from some reason (of the FILTER parameter for example)
8080
modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
81-
QgsDebugMsg( QString( "Get %1" ).arg( modifiedUrlString ) );
81+
QgsDebugMsg( QStringLiteral( "Get %1" ).arg( modifiedUrlString ) );
8282
modifiedUrlString = modifiedUrlString.mid( QStringLiteral( "http://" ).size() );
8383
QString args = modifiedUrlString.mid( modifiedUrlString.indexOf( '?' ) );
8484
if ( modifiedUrlString.size() > 256 )
@@ -280,7 +280,7 @@ void QgsWfsRequest::abort()
280280

281281
void QgsWfsRequest::replyProgress( qint64 bytesReceived, qint64 bytesTotal )
282282
{
283-
QgsDebugMsg( QStringLiteral( "%1 of %2 bytes downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) ) );
283+
QgsDebugMsg( QStringLiteral( "%1 of %2 bytes downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QStringLiteral( "unknown number of" ) : QString::number( bytesTotal ) ) );
284284

285285
if ( bytesReceived != 0 )
286286
mGotNonEmptyResponse = true;
@@ -307,11 +307,11 @@ void QgsWfsRequest::replyFinished()
307307
{
308308
if ( mReply->error() == QNetworkReply::NoError )
309309
{
310-
QgsDebugMsg( "reply OK" );
310+
QgsDebugMsg( QStringLiteral( "reply OK" ) );
311311
QVariant redirect = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
312312
if ( !redirect.isNull() )
313313
{
314-
QgsDebugMsg( "Request redirected." );
314+
QgsDebugMsg( QStringLiteral( "Request redirected." ) );
315315

316316
const QUrl &toUrl = redirect.toUrl();
317317
mReply->request();
@@ -339,7 +339,7 @@ void QgsWfsRequest::replyFinished()
339339
mReply->deleteLater();
340340
mReply = nullptr;
341341

342-
QgsDebugMsg( QString( "redirected: %1 forceRefresh=%2" ).arg( redirect.toString() ).arg( mForceRefresh ) );
342+
QgsDebugMsg( QStringLiteral( "redirected: %1 forceRefresh=%2" ).arg( redirect.toString() ).arg( mForceRefresh ) );
343343
mReply = QgsNetworkAccessManager::instance()->get( request );
344344
mReply->setReadBufferSize( READ_BUFFER_SIZE_HINT );
345345
if ( !mUri.auth().setAuthorizationReply( mReply ) )
@@ -372,7 +372,7 @@ void QgsWfsRequest::replyFinished()
372372
}
373373
cmd.setRawHeaders( hl );
374374

375-
QgsDebugMsg( QString( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
375+
QgsDebugMsg( QStringLiteral( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
376376
if ( cmd.expirationDate().isNull() )
377377
{
378378
cmd.setExpirationDate( QDateTime::currentDateTime().addSecs( defaultExpirationInSec() ) );
@@ -382,12 +382,12 @@ void QgsWfsRequest::replyFinished()
382382
}
383383
else
384384
{
385-
QgsDebugMsg( "No cache!" );
385+
QgsDebugMsg( QStringLiteral( "No cache!" ) );
386386
}
387387

388388
#ifdef QGISDEBUG
389389
bool fromCache = mReply->attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool();
390-
QgsDebugMsg( QString( "Reply was cached: %1" ).arg( fromCache ) );
390+
QgsDebugMsg( QStringLiteral( "Reply was cached: %1" ).arg( fromCache ) );
391391
#endif
392392

393393
mResponse = mReply->readAll();

‎src/providers/wfs/qgswfsshareddata.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool QgsWFSSharedData::createCache()
219219
Q_ASSERT( !QFile::exists( mCacheDbname ) );
220220

221221
QgsFields cacheFields;
222-
Q_FOREACH ( const QgsField &field, mFields )
222+
for ( const QgsField &field : qgis::as_const( mFields ) )
223223
{
224224
QVariant::Type type = field.type();
225225
// Map DateTime to int64 milliseconds from epoch
@@ -261,11 +261,11 @@ bool QgsWFSSharedData::createCache()
261261
vsimemFilename.sprintf( "/vsimem/qgis_wfs_cache_template_%p/features.sqlite", this );
262262
mCacheTablename = CPLGetBasename( vsimemFilename.toStdString().c_str() );
263263
VSIUnlink( vsimemFilename.toStdString().c_str() );
264-
QgsVectorFileWriter *writer = new QgsVectorFileWriter( vsimemFilename, QLatin1String( "" ),
264+
std::unique_ptr< QgsVectorFileWriter > writer = qgis::make_unique< QgsVectorFileWriter >( vsimemFilename, QString(),
265265
cacheFields, QgsWkbTypes::Polygon, QgsCoordinateReferenceSystem(), QStringLiteral( "SpatiaLite" ), datasourceOptions, layerOptions );
266266
if ( writer->hasError() == QgsVectorFileWriter::NoError )
267267
{
268-
delete writer;
268+
writer.reset();
269269

270270
// Copy the temporary database back to disk
271271
vsi_l_offset nLength = 0;
@@ -293,7 +293,7 @@ bool QgsWFSSharedData::createCache()
293293
// not define SPATIALITE_412_OR_LATER, and thus the call to
294294
// spatialite_init() may cause failures, which will require using the
295295
// slower method
296-
delete writer;
296+
writer.reset();
297297
VSIUnlink( vsimemFilename.toStdString().c_str() );
298298
}
299299
}
@@ -446,7 +446,7 @@ bool QgsWFSSharedData::createCache()
446446
// regarding crashes, since this is a temporary DB
447447
QgsDataSourceUri dsURI;
448448
dsURI.setDatabase( mCacheDbname );
449-
dsURI.setDataSource( QLatin1String( "" ), mCacheTablename, geometryFieldname, QLatin1String( "" ), fidName );
449+
dsURI.setDataSource( QString(), mCacheTablename, geometryFieldname, QString(), fidName );
450450
QStringList pragmas;
451451
pragmas << QStringLiteral( "synchronous=OFF" );
452452
pragmas << QStringLiteral( "journal_mode=WAL" ); // WAL is needed to avoid reader to block writers

0 commit comments

Comments
 (0)
Please sign in to comment.