Skip to content

Commit

Permalink
Remove unused variables, also avoid some unnecessary string creation
Browse files Browse the repository at this point in the history
when not using debug builds
  • Loading branch information
nyalldawson committed May 15, 2016
1 parent bf76049 commit d255bfb
Show file tree
Hide file tree
Showing 54 changed files with 86 additions and 185 deletions.
7 changes: 4 additions & 3 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -584,9 +584,7 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
QColor bg( Qt::white ); // moved several items outside of the following if block to minimize loop time
bg.setAlpha( 200 );
QColor myColor;
QBrush symbolBrush( Qt::black );
QBrush textBgBrush( bg );
QSize markerSize( 9, 9 );

// Add a marker to the polar plot
if ( currentInfo.id > 0 ) // don't show satellite if id=0 (no satellite indication)
{
Expand All @@ -607,6 +605,9 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
myColor = Qt::black; //strong signal
}
#ifdef WITH_QWTPOLAR
QBrush symbolBrush( Qt::black );
QSize markerSize( 9, 9 );
QBrush textBgBrush( bg );
#if (QWT_POLAR_VERSION<0x010000)
mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
symbolBrush, QPen( myColor ), markerSize ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Expand Up @@ -936,7 +936,7 @@ int main( int argc, char *argv[] )
QString i18nPath = QgsApplication::i18nPath();
QString myUserLocale = mySettings.value( "locale/userLocale", "" ).toString();
bool myLocaleOverrideFlag = mySettings.value( "locale/overrideFlag", false ).toBool();
QString myLocale;

//
// Priority of translation is:
// - command line
Expand Down
24 changes: 2 additions & 22 deletions src/app/qgisapp.cpp
Expand Up @@ -10477,8 +10477,6 @@ void QgisApp::refreshActionFeatureAction()
// this is a slot for action from GUI to add raster layer
void QgisApp::addRasterLayer()
{
QString fileFilters;

QStringList selectedFiles;
QString e;//only for parameter correctness
QString title = tr( "Open a GDAL Supported Raster Data Source" );
Expand Down Expand Up @@ -10856,6 +10854,7 @@ void QgisApp::showBookmarks()

void QgisApp::oldProjectVersionWarning( const QString& oldVersion )
{
Q_UNUSED( oldVersion );
QSettings settings;

if ( settings.value( "/qgis/warnOldProjectVersion", QVariant( true ) ).toBool() )
Expand All @@ -10864,24 +10863,6 @@ void QgisApp::oldProjectVersionWarning( const QString& oldVersion )
" When saving this project file, QGIS will update it to the latest version, "
"possibly rendering it useless for older versions of QGIS." );

QString text = tr( "<p>This project file was saved by an older version of QGIS."
" When saving this project file, QGIS will update it to the latest version, "
"possibly rendering it useless for older versions of QGIS."
"<p>Even though QGIS developers try to maintain backwards "
"compatibility, some of the information from the old project "
"file might be lost."
" To improve the quality of QGIS, we appreciate "
"if you file a bug report at %3."
" Be sure to include the old project file, and state the version of "
"QGIS you used to discover the error."
"<p>To remove this warning when opening an older project file, "
"uncheck the box '%5' in the %4 menu."
"<p>Version of the project file: %1<br>Current version of QGIS: %2" )
.arg( oldVersion,
QGis::QGIS_VERSION,
"<a href=\"https://hub.qgis.org/projects/quantum-gis\">https://hub.qgis.org/projects/quantum-gis</a> ",
tr( "<tt>Settings:Options:General</tt>", "Menu path to setting options" ),
tr( "Warn me when opening a project file saved with an older version of QGIS" ) );
QString title = tr( "Project file is older" );

#ifdef ANDROID
Expand Down Expand Up @@ -11225,8 +11206,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
timer->stop();
}

QString requesturl = reply->request().url().toString();
QgsDebugMsg( QString( "SSL errors occurred accessing URL:\n%1" ).arg( requesturl ) );
QgsDebugMsg( QString( "SSL errors occurred accessing URL:\n%1" ).arg( reply->request().url().toString() ) );

QString hostport( QString( "%1:%2" )
.arg( reply->url().host() )
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -122,7 +122,6 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem* item )
QgsMapLayer::LayerType type = layerItem->mapLayerType();
QString layerMetadata = tr( "Error" );
QgsCoordinateReferenceSystem layerCrs;
QString notice;

// temporarily override /Projections/defaultBehaviour to avoid dialog prompt
QSettings settings;
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgshandlebadlayers.cpp
Expand Up @@ -368,8 +368,6 @@ void QgsHandleBadLayers::apply()
int idx = mLayerList->item( i, 0 )->data( Qt::UserRole ).toInt();
QDomNode &node = const_cast<QDomNode &>( mLayers[ idx ] );

QString type = mLayerList->item( i, 1 )->text();
QString provider = mLayerList->item( i, 2 )->text();
QTableWidgetItem *item = mLayerList->item( i, 4 );
QString datasource = item->text();

Expand Down
1 change: 1 addition & 0 deletions src/app/qgslabeldialog.cpp
Expand Up @@ -279,6 +279,7 @@ void QgsLabelDialog::changeFont()
qreal fontSize = mFont.pointSizeF();
bool resultFlag;
QFont newFont = QgisGui::getFont( resultFlag, mFont );
Q_UNUSED( newFont );
if ( !resultFlag )
return;

Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -634,7 +634,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandSingleByte, "multiBandSingleByte", "NoEnhancement" );
initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandMultiByte, "multiBandMultiByte", "StretchToMinimumMaximum" );

QString cumulativeCutText = tr( "Cumulative pixel count cut" );
cboxContrastEnhancementLimits->addItem( tr( "Cumulative pixel count cut" ), "CumulativeCut" );
cboxContrastEnhancementLimits->addItem( tr( "Minimum / maximum" ), "MinMax" );
cboxContrastEnhancementLimits->addItem( tr( "Mean +/- standard deviation" ), "StdDev" );
Expand Down Expand Up @@ -807,7 +806,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )

//set elements in digitizing tab
mLineWidthSpinBox->setValue( mSettings->value( "/qgis/digitizing/line_width", 1 ).toInt() );
QColor digitizingColor;
myRed = mSettings->value( "/qgis/digitizing/line_color_red", 255 ).toInt();
myGreen = mSettings->value( "/qgis/digitizing/line_color_green", 0 ).toInt();
myBlue = mSettings->value( "/qgis/digitizing/line_color_blue", 0 ).toInt();
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -901,7 +901,6 @@ void QgsVectorLayerProperties::saveStyleAs( StyleType styleType )
QSettings myQSettings; // where we keep last used filter in persistent state
QString myLastUsedDir = myQSettings.value( "style/lastStyleDir", QDir::homePath() ).toString();

QString format, extension;
if ( styleType == DB )
{
QString infoWindowTitle = QObject::tr( "Save style to DB (%1)" ).arg( mLayer->providerType() );
Expand Down
4 changes: 0 additions & 4 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -395,8 +395,6 @@ QFont QgsComposerLabel::font() const

bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
QString alignment;

if ( elem.isNull() )
{
return false;
Expand Down Expand Up @@ -429,8 +427,6 @@ bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const

bool QgsComposerLabel::readXML( const QDomElement& itemElem, const QDomDocument& doc )
{
QString alignment;

if ( itemElem.isNull() )
{
return false;
Expand Down
1 change: 0 additions & 1 deletion src/core/composer/qgslegendmodel.cpp
Expand Up @@ -784,7 +784,6 @@ bool QgsLegendModel::removeRows( int row, int count, const QModelIndex & parent
QMimeData* QgsLegendModel::mimeData( const QModelIndexList &indexes ) const
{
QMimeData* mimeData = new QMimeData();
QByteArray encodedData;
QDomDocument xmlDoc;
QDomElement xmlRootElement = xmlDoc.createElement( "LegendModelDragData" );
xmlDoc.appendChild( xmlRootElement );
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsdataitem.cpp
Expand Up @@ -1442,7 +1442,6 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, const QString& fileP
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser2", "basic" ).toString();
int zipFileCount = 0;
QStringList zipFileList;
QFileInfo fileInfo( filePath );
QString vsiPrefix = QgsZipItem::vsiPrefix( filePath );
QgsZipItem * zipItem = nullptr;
bool populated = false;
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsdiagramrendererv2.cpp
Expand Up @@ -371,7 +371,6 @@ void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc,
categoryElem.setAttribute( "minimumSize", QString::number( minimumSize ) );
categoryElem.setAttribute( "angleOffset", QString::number( angleOffset ) );

QString colors;
int nCats = qMin( categoryColors.size(), categoryAttributes.size() );
for ( int i = 0; i < nCats; ++i )
{
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgserror.cpp
Expand Up @@ -51,7 +51,10 @@ QString QgsError::message( QgsErrorMessage::Format theFormat ) const
{
QString str;

#ifdef QGISDEBUG
QString srcUrl;
#endif

#if defined(QGISDEBUG) && defined(QGS_GIT_REMOTE_URL)
// TODO: verify if we are not ahead to origin (remote hash does not exist)
// and there are no local not commited changes
Expand Down
11 changes: 5 additions & 6 deletions src/core/qgsfontutils.cpp
Expand Up @@ -239,12 +239,11 @@ bool QgsFontUtils::loadStandardTestFonts( const QStringList& loadstyles )
{
continue;
}
QString familyStyle = QString( "%1 %2" ).arg( fontFamily, fontstyle );

if ( fontFamilyHasStyle( fontFamily, fontstyle ) )
{
fontsLoaded = ( fontsLoaded || false );
QgsDebugMsg( QString( "Test font '%1' already available" ).arg( familyStyle ) );
QgsDebugMsg( QString( "Test font '%1 %2' already available" ).arg( fontFamily, fontstyle ) );
}
else
{
Expand All @@ -259,8 +258,8 @@ bool QgsFontUtils::loadStandardTestFonts( const QStringList& loadstyles )
int fontID = QFontDatabase::addApplicationFont( fontPath );
loaded = ( fontID != -1 );
fontsLoaded = ( fontsLoaded || loaded );
QgsDebugMsg( QString( "Test font '%1' %2 from filesystem [%3]" )
.arg( familyStyle, loaded ? "loaded" : "FAILED to load", fontPath ) );
QgsDebugMsg( QString( "Test font '%1 %2' %3 from filesystem [%4]" )
.arg( fontFamily, fontstyle, loaded ? "loaded" : "FAILED to load", fontPath ) );
QFontDatabase db;
QgsDebugMsg( QString( "font families in %1: %2" ).arg( fontID ).arg( db.applicationFontFamilies( fontID ).join( "," ) ) );
}
Expand All @@ -273,8 +272,8 @@ bool QgsFontUtils::loadStandardTestFonts( const QStringList& loadstyles )
loaded = ( fontID != -1 );
fontsLoaded = ( fontsLoaded || loaded );
}
QgsDebugMsg( QString( "Test font '%1' %2 from testdata.qrc" )
.arg( familyStyle, loaded ? "loaded" : "FAILED to load" ) );
QgsDebugMsg( QString( "Test font '%1' %3 from testdata.qrc" )
.arg( fontFamily, fontstyle, loaded ? "loaded" : "FAILED to load" ) );
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsmaprenderercustompainterjob.cpp
Expand Up @@ -71,10 +71,11 @@ void QgsMapRendererCustomPainterJob::start()

mPainter->setRenderHint( QPainter::Antialiasing, mSettings.testFlag( QgsMapSettings::Antialiasing ) );

#ifndef QT_NO_DEBUG
QPaintDevice* thePaintDevice = mPainter->device();

QString errMsg = QString( "pre-set DPI not equal to painter's DPI (%1 vs %2)" ).arg( thePaintDevice->logicalDpiX() ).arg( mSettings.outputDpi() );
Q_ASSERT_X( thePaintDevice->logicalDpiX() == mSettings.outputDpi(), "Job::startRender()", errMsg.toAscii().data() );
#endif

delete mLabelingEngine;
mLabelingEngine = nullptr;
Expand Down
6 changes: 0 additions & 6 deletions src/core/qgsogcutils.cpp
Expand Up @@ -914,12 +914,6 @@ QgsRectangle QgsOgcUtils::rectangleFromGMLBox( const QDomNode& boxNode )

bool QgsOgcUtils::readGMLPositions( QgsPolyline &coords, const QDomElement &elem )
{
//tupel and coord separator are the same
QString coordSeparator = " ";
QString tupelSeparator = " ";
//"decimal" has to be "."


coords.clear();

QStringList pos = elem.text().split( ' ', QString::SkipEmptyParts );
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgspallabeling.cpp
Expand Up @@ -3015,7 +3015,9 @@ bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
{
if ( dataDefinedEvaluate( p, exprVal, &context, originalValue ) )
{
QString dbgStr = QString( "exprVal %1:" ).arg( mDataDefinedNames.value( p ).first ) + "%1";
#ifdef QGISDEBUG
QString dbgStr = QString( "exprVal %1:" ).arg( mDataDefinedNames.value( p ).first ) + "%1"; // clazy:exclude=unused-non-trivial-variable
#endif

switch ( valType )
{
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -1134,7 +1134,6 @@ bool QgsProject::write()

if ( ml )
{
QString externalProjectFile = layerIsEmbedded( ml->id() );
QHash< QString, QPair< QString, bool> >::const_iterator emIt = mEmbeddedLayers.constFind( ml->id() );
if ( emIt == mEmbeddedLayers.constEnd() )
{
Expand Down
4 changes: 1 addition & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -882,9 +882,7 @@ QgsRectangle QgsVectorLayer::extent()
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QString s = mbr.toString();

QgsDebugMsg( "Extent of layer: " + s );
QgsDebugMsg( "Extent of layer: " + mbr.toString() );
// store the extent
setExtent( mbr );

Expand Down
9 changes: 2 additions & 7 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -679,8 +679,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QString s = mbr.toString();
QgsDebugMsgLevel( "Extent of layer: " + s, 4 );
QgsDebugMsgLevel( "Extent of layer: " + mbr.toString(), 4 );
// store the extent
setExtent( mbr );

Expand All @@ -693,15 +692,11 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
// Setup source CRS
setCrs( QgsCoordinateReferenceSystem( mDataProvider->crs() ) );

QString mySourceWkt = crs().toWkt();

QgsDebugMsgLevel( "using wkt:\n" + mySourceWkt, 4 );
QgsDebugMsgLevel( "using wkt:\n" + crs().toWkt(), 4 );

//defaults - Needs to be set after the Contrast list has been build
//Try to read the default contrast enhancement from the config file

QSettings myQSettings;

//decide what type of layer this is...
//TODO Change this to look at the color interp and palette interp to decide which type of layer it is
QgsDebugMsgLevel( "bandCount = " + QString::number( mDataProvider->bandCount() ), 4 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgscptcityarchive.cpp
Expand Up @@ -967,7 +967,7 @@ QMap< QString, QStringList > QgsCptCityDirectoryItem::rampsMap()
if ( ! mRampsMap.isEmpty() )
return mRampsMap;

QString curName, prevName, prevPath, curVariant, curSep, schemeName;
QString curName, prevName, curVariant, curSep, schemeName;
QStringList listVariant;
QStringList schemeNamesAll, schemeNames;
bool prevAdd, curAdd;
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgssinglesymbolrendererv2.cpp
Expand Up @@ -208,7 +208,6 @@ QgsSingleSymbolRendererV2* QgsSingleSymbolRendererV2::clone() const
void QgsSingleSymbolRendererV2::toSld( QDomDocument& doc, QDomElement &element ) const
{
QgsStringMap props;
QString errorMsg;
if ( mRotation.data() )
props[ "angle" ] = mRotation->expression();
if ( mSizeScale.data() )
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgsstylev2.cpp
Expand Up @@ -1311,7 +1311,6 @@ QgsSmartConditionMap QgsStyleV2::smartgroup( int id )
}

QDomElement smartEl = doc.documentElement();
QString op = smartEl.attribute( "operator" );
QDomNodeList conditionNodes = smartEl.childNodes();

for ( int i = 0; i < conditionNodes.count(); i++ )
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgssvgcache.cpp
Expand Up @@ -756,7 +756,6 @@ void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillPara
{
continue;
}
QString key = keyValueSplit.at( 0 );
QString value = keyValueSplit.at( 1 );
valueSplit = value.split( ' ' );
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
Expand Down
3 changes: 1 addition & 2 deletions src/gui/qgsbrowsertreeview.cpp
Expand Up @@ -107,8 +107,7 @@ void QgsBrowserTreeView::expandTree( const QModelIndex & index )
if ( !model() )
return;

QString itemPath = model()->data( index, QgsBrowserModel::PathRole ).toString();
QgsDebugMsg( "itemPath = " + itemPath );
QgsDebugMsg( "itemPath = " + model()->data( index, QgsBrowserModel::PathRole ).toString() );

expand( index );
QModelIndex parentIndex = model()->parent( index );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgscomposerruler.cpp
Expand Up @@ -361,8 +361,10 @@ int QgsComposerRuler::optimumNumberDivisions( double rulerScale, int scaleMultip

void QgsComposerRuler::setSceneTransform( const QTransform& transform )
{
#if 0
QString debug = QString::number( transform.dx() ) + ',' + QString::number( transform.dy() ) + ','
+ QString::number( transform.m11() ) + ',' + QString::number( transform.m22() );
#endif
mTransform = transform;
update();
}
Expand Down
4 changes: 0 additions & 4 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1180,10 +1180,6 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
return;
}

QPainter paint;
QPen pen( Qt::gray );
QgsPoint ll, ur;

if ( ! mCanvasProperties->mouseButtonDown )
{
// Don't want to interfer with mouse events
Expand Down
2 changes: 1 addition & 1 deletion src/gui/raster/qgsrasterhistogramwidget.cpp
Expand Up @@ -688,7 +688,7 @@ void QgsRasterHistogramWidget::on_mSaveAsImageButton_clicked()

QPair< QString, QString> myFileNameAndFilter = QgisGui::getSaveAsImageName( this, tr( "Choose a file name to save the map image as" ) );
QFileInfo myInfo( myFileNameAndFilter.first );
if ( QFileInfo( myFileNameAndFilter.first ).baseName() != "" )
if ( myInfo.baseName() != "" )
{
histoSaveAsImage( myFileNameAndFilter.first );
}
Expand Down
3 changes: 1 addition & 2 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -1096,8 +1096,7 @@ void QgsStyleV2ManagerDialog::removeGroup()

void QgsStyleV2ManagerDialog::groupRenamed( QStandardItem * item )
{
QString data = item->data( Qt::UserRole + 1 ).toString();
QgsDebugMsg( "Symbol group edited: data=" + data + " text=" + item->text() );
QgsDebugMsg( "Symbol group edited: data=" + item->data( Qt::UserRole + 1 ).toString() + " text=" + item->text() );
int id = item->data( Qt::UserRole + 1 ).toInt();
QString name = item->text();
if ( item->parent()->data( Qt::UserRole + 1 ) == "smartgroups" )
Expand Down
2 changes: 0 additions & 2 deletions src/gui/symbology-ng/qgssymbolslistwidget.cpp
Expand Up @@ -182,8 +182,6 @@ void QgsSymbolsListWidget::populateSymbolView()
void QgsSymbolsListWidget::populateSymbols( const QStringList& names )
{
QSize previewSize = viewSymbols->iconSize();
QPixmap p( previewSize );
QPainter painter;

QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
if ( !model )
Expand Down

0 comments on commit d255bfb

Please sign in to comment.