Skip to content

Commit f267215

Browse files
committed
Fix clazy qfileinfo-exists warnings
From the clazy docs: Finds places using QFileInfo("foo").exists() instead of the faster version QFileInfo::exists("foo"). According to Qt's docs: "Using this function is faster than using QFileInfo(file).exists() for file system access."
1 parent ef51107 commit f267215

13 files changed

+22
-22
lines changed

src/app/openstreetmap/qgsosmimportdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void QgsOSMImportDialog::dbFileNameChanged( const QString& fileName )
8484
void QgsOSMImportDialog::onOK()
8585
{
8686
// output file exists?
87-
if ( QFileInfo( editDbFileName->text() ).exists() )
87+
if ( QFileInfo::exists( editDbFileName->text() ) )
8888
{
8989
int res = QMessageBox::question( this, tr( "OpenStreetMap import" ), tr( "Output database file exists already. Overwrite?" ), QMessageBox::Yes | QMessageBox::No );
9090
if ( res != QMessageBox::Yes )

src/app/qgisapp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ void QgisApp::createActions()
17651765
mActionReportaBug->setShortcut( QString() );
17661766
#endif
17671767

1768-
mActionHelpContents->setEnabled( QFileInfo( QgsApplication::pkgDataPath() + "/doc/index.html" ).exists() );
1768+
mActionHelpContents->setEnabled( QFileInfo::exists( QgsApplication::pkgDataPath() + "/doc/index.html" ) );
17691769

17701770
connect( mActionHelpContents, SIGNAL( triggered() ), this, SLOT( helpContents() ) );
17711771
connect( mActionHelpAPI, SIGNAL( triggered() ), this, SLOT( apiDocumentation() ) );
@@ -9185,7 +9185,7 @@ void QgisApp::helpContents()
91859185

91869186
void QgisApp::apiDocumentation()
91879187
{
9188-
if ( QFileInfo( QgsApplication::pkgDataPath() + "/doc/api/index.html" ).exists() )
9188+
if ( QFileInfo::exists( QgsApplication::pkgDataPath() + "/doc/api/index.html" ) )
91899189
{
91909190
openURL( "api/index.html" );
91919191
}

src/app/qgshandlebadlayers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ QString QgsHandleBadLayers::filename( int row )
209209

210210
void QgsHandleBadLayers::setFilename( int row, const QString& filename )
211211
{
212-
if ( !QFileInfo( filename ).exists() )
212+
if ( !QFileInfo::exists( filename ) )
213213
return;
214214

215215
QString type = mLayerList->item( row, 1 )->text();

src/core/gps/qgsgpsdetector.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ QList< QPair<QString, QString> > QgsGPSDetector::availablePorts()
4848
{
4949
for ( int i = 0; i < 10; ++i )
5050
{
51-
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
51+
if ( QFileInfo::exists( linuxDev.arg( i ) ) )
5252
{
5353
devs << QPair<QString, QString>( linuxDev.arg( i ), linuxDev.arg( i ) );
5454
}

src/gui/qgscodeeditorpython.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void QgsCodeEditorPython::setSciLexerPython()
7474
}
7575
else if ( mAPISFilesList.length() == 1 && mAPISFilesList[0].right( 3 ) == "pap" )
7676
{
77-
if ( !QFileInfo( mAPISFilesList[0] ).exists() )
77+
if ( !QFileInfo::exists( mAPISFilesList[0] ) )
7878
{
7979
QgsDebugMsg( QString( "The apis file %1 not found" ).arg( mAPISFilesList.at( 0 ) ) );
8080
return;
@@ -86,7 +86,7 @@ void QgsCodeEditorPython::setSciLexerPython()
8686
{
8787
for ( int i = 0; i < mAPISFilesList.size(); i++ )
8888
{
89-
if ( !QFileInfo( mAPISFilesList[i] ).exists() )
89+
if ( !QFileInfo::exists( mAPISFilesList[i] ) )
9090
{
9191
QgsDebugMsg( QString( "The apis file %1 was not found" ).arg( mAPISFilesList.at( i ) ) );
9292
return;

src/gui/qgsprojectionselector.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ QString QgsProjectionSelector::selectedProj4String()
308308
if ( srsId.toLong() >= USER_CRS_START_ID )
309309
{
310310
databaseFileName = QgsApplication::qgisUserDbFilePath();
311-
if ( !QFileInfo( databaseFileName ).exists() ) //its unlikely that this condition will ever be reached
311+
if ( !QFileInfo::exists( databaseFileName ) ) //its unlikely that this condition will ever be reached
312312
return QString();
313313
}
314314
else //must be a system projection then
@@ -372,7 +372,7 @@ QString QgsProjectionSelector::getSelectedExpression( const QString& expression
372372
if ( lvi->text( QGIS_CRS_ID_COLUMN ).toLong() >= USER_CRS_START_ID )
373373
{
374374
databaseFileName = QgsApplication::qgisUserDbFilePath();
375-
if ( !QFileInfo( databaseFileName ).exists() )
375+
if ( !QFileInfo::exists( databaseFileName ) )
376376
{
377377
return QString();
378378
}
@@ -483,7 +483,7 @@ void QgsProjectionSelector::loadUserCrsList( QSet<QString> *crsFilter )
483483
// if it doesnt exist we copy it in from the global resources dir
484484

485485
//return straight away if the user has not created any custom projections
486-
if ( !QFileInfo( databaseFileName ).exists() )
486+
if ( !QFileInfo::exists( databaseFileName ) )
487487
{
488488
QgsDebugMsg( "Users qgis.db not found...skipping" );
489489
mUserProjListDone = true;
@@ -566,7 +566,7 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
566566
//read only filesystem because otherwise sqlite will try
567567
//to create the db file on the fly
568568

569-
if ( !QFileInfo( mSrsDatabaseFileName ).exists() )
569+
if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
570570
{
571571
mProjListDone = true;
572572
return;
@@ -888,7 +888,7 @@ long QgsProjectionSelector::getLargestCrsIdMatch( const QString& theSql )
888888

889889
//check the db is available
890890
QString databaseFileName = QgsApplication::qgisUserDbFilePath();
891-
if ( QFileInfo( databaseFileName ).exists() ) //only bother trying to open if the file exists
891+
if ( QFileInfo::exists( databaseFileName ) ) //only bother trying to open if the file exists
892892
{
893893
result = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
894894
if ( result )

src/gui/symbology-ng/qgssymbollayerwidget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ void QgsSvgMarkerSymbolLayerWidget::on_mFileToolButton_clicked()
20362036

20372037
void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_textEdited( const QString& text )
20382038
{
2039-
if ( !QFileInfo( text ).exists() )
2039+
if ( !QFileInfo::exists( text ) )
20402040
{
20412041
return;
20422042
}
@@ -2047,7 +2047,7 @@ void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_textEdited( const QString&
20472047

20482048
void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_editingFinished()
20492049
{
2050-
if ( !QFileInfo( mFileLineEdit->text() ).exists() )
2050+
if ( !QFileInfo::exists( mFileLineEdit->text() ) )
20512051
{
20522052
QUrl url( mFileLineEdit->text() );
20532053
if ( !url.isValid() )

src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ bool QgsDelimitedTextSourceSelect::validate()
670670
{
671671
message = tr( "Please select an input file" );
672672
}
673-
else if ( ! QFileInfo( txtFilePath->text() ).exists() )
673+
else if ( ! QFileInfo::exists( txtFilePath->text() ) )
674674
{
675675
message = tr( "File %1 does not exist" ).arg( txtFilePath->text() );
676676
}

src/providers/grass/qgsgrass.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void QgsGrass::setMapsetSearchPathWatcher()
759759

760760
QString searchFilePath = getDefaultMapsetPath() + "/SEARCH_PATH";
761761

762-
if ( QFileInfo( searchFilePath ).exists() )
762+
if ( QFileInfo::exists( searchFilePath ) )
763763
{
764764
QgsDebugMsg( "add watcher on SEARCH_PATH file " + searchFilePath );
765765
mMapsetSearchPathWatcher->addPath( searchFilePath );
@@ -781,7 +781,7 @@ void QgsGrass::onSearchPathFileChanged( const QString & path )
781781
{
782782
// changed or removed
783783
loadMapsetSearchPath();
784-
if ( !QFileInfo( searchFilePath ).exists() ) // removed
784+
if ( !QFileInfo::exists( searchFilePath ) ) // removed
785785
{
786786
// reset watcher to mapset
787787
setMapsetSearchPathWatcher();
@@ -790,7 +790,7 @@ void QgsGrass::onSearchPathFileChanged( const QString & path )
790790
else
791791
{
792792
// mapset directory changed
793-
if ( QFileInfo( searchFilePath ).exists() ) // search path file added
793+
if ( QFileInfo::exists( searchFilePath ) ) // search path file added
794794
{
795795
loadMapsetSearchPath();
796796
setMapsetSearchPathWatcher();

src/providers/grass/qgsgrassimport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ bool QgsGrassExternal::import()
804804
QString cmd = QgsGrass::gisbase() + "/bin/r.external";
805805
QStringList arguments;
806806

807-
if ( QFileInfo( mSource ).exists() )
807+
if ( QFileInfo::exists( mSource ) )
808808
{
809809
arguments << "input=" + mSource;
810810
}

src/providers/grass/qgsgrassvectormap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ bool QgsGrassVectorMap::mapOutdated()
504504
{
505505
// If the cidx file has been deleted, the map is currently being modified
506506
// by an external tool. Do not update until the cidx file has been recreated.
507-
if ( !QFileInfo( dp + "/cidx" ).exists() )
507+
if ( !QFileInfo::exists( dp + "/cidx" ) )
508508
{
509509
QgsDebugMsg( "The map is being modified and is unavailable : " + mGrassObject.toString() );
510510
return false;

src/providers/ogr/qgsogrdataitems.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
298298
if ( suffix == "dbf" )
299299
{
300300
QString pathShp = thePath.left( thePath.count() - 4 ) + ".shp";
301-
if ( QFileInfo( pathShp ).exists() )
301+
if ( QFileInfo::exists( pathShp ) )
302302
return nullptr;
303303
}
304304

tests/src/providers/testqgswcspublicservers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void TestQgsWcsPublicServers::test()
374374
QString myPath = myVersionDirPath + '/' + myCoverage.identifier;
375375
QString myLogPath = myPath + ".log";
376376

377-
if ( QFileInfo( myLogPath ).exists() && !mForce )
377+
if ( QFileInfo::exists( myLogPath ) && !mForce )
378378
{
379379
//QMap<QString, QString> log = readLog( myLogPath );
380380
//if ( !log.value( "identifier" ).isEmpty() && log.value( "error" ).isEmpty() ) continue;

0 commit comments

Comments
 (0)