Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Coverity fixes
  • Loading branch information
nyalldawson committed Sep 28, 2015
1 parent 7c03619 commit c5f464b
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Expand Up @@ -36,6 +36,7 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
, mNodeEditor( 0 )
, mMoving( true )
, mSelectAnother( false )
, mAnother( 0 )
, mSelectionRubberBand( 0 )
, mRect( 0 )
, mIsPoint( false )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -9555,7 +9555,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionCopyFeatures->setEnabled( layerHasSelection );
mActionFeatureAction->setEnabled( layerHasActions );

if ( !isEditable && mMapCanvas->mapTool()
if ( !isEditable && mMapCanvas && mMapCanvas->mapTool()
&& mMapCanvas->mapTool()->isEditTool() && !mSaveRollbackInProgress )
{
mMapCanvas->setMapTool( mNonEditMapTool );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -744,7 +744,7 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )
{
str = query;
}
else
else if ( mCurrentSearchWidgetWrapper )
{
str = mCurrentSearchWidgetWrapper->expression();
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsvariantdelegate.cpp
Expand Up @@ -189,7 +189,7 @@ void QgsVariantDelegate::setModelData( QWidget* editor, QAbstractItemModel* mode
value = text.at( 0 );
break;
case QVariant::Color:
mColorExp.exactMatch( text );
( void )mColorExp.exactMatch( text );
value = QColor( qMin( mColorExp.cap( 1 ).toInt(), 255 ),
qMin( mColorExp.cap( 2 ).toInt(), 255 ),
qMin( mColorExp.cap( 3 ).toInt(), 255 ),
Expand All @@ -212,16 +212,16 @@ void QgsVariantDelegate::setModelData( QWidget* editor, QAbstractItemModel* mode
}
break;
case QVariant::Point:
mPointExp.exactMatch( text );
( void )mPointExp.exactMatch( text );
value = QPoint( mPointExp.cap( 1 ).toInt(), mPointExp.cap( 2 ).toInt() );
break;
case QVariant::Rect:
mRectExp.exactMatch( text );
( void )mRectExp.exactMatch( text );
value = QRect( mRectExp.cap( 1 ).toInt(), mRectExp.cap( 2 ).toInt(),
mRectExp.cap( 3 ).toInt(), mRectExp.cap( 4 ).toInt() );
break;
case QVariant::Size:
mSizeExp.exactMatch( text );
( void )mSizeExp.exactMatch( text );
value = QSize( mSizeExp.cap( 1 ).toInt(), mSizeExp.cap( 2 ).toInt() );
break;
case QVariant::StringList:
Expand Down
4 changes: 2 additions & 2 deletions src/core/auth/qgsauthmanager.cpp
Expand Up @@ -84,7 +84,7 @@ QSqlDatabase QgsAuthManager::authDbConnection() const
authdb = QSqlDatabase::database( connectionname );
}
if ( !authdb.isOpen() )
authdb.open();
( void )authdb.open();

return authdb;
}
Expand Down Expand Up @@ -3230,7 +3230,7 @@ bool QgsAuthManager::authDbQuery( QSqlQuery *query ) const
return false;

query->setForwardOnly( true );
query->exec();
( void )query->exec();

if ( query->lastError().isValid() )
{
Expand Down
20 changes: 14 additions & 6 deletions src/core/pal/pal.cpp
Expand Up @@ -43,6 +43,7 @@
#include "labelposition.h"
#include "problem.h"
#include "pointset.h"
#include "internalexception.h"
#include "util.h"
#include <QTime>
#include <cstdarg>
Expand Down Expand Up @@ -586,12 +587,19 @@ namespace pal

prob->reduce();

if ( searchMethod == FALP )
prob->init_sol_falp();
else if ( searchMethod == CHAIN )
prob->chain_search();
else
prob->popmusic();
try
{
if ( searchMethod == FALP )
prob->init_sol_falp();
else if ( searchMethod == CHAIN )
prob->chain_search();
else
prob->popmusic();
}
catch ( InternalException::Empty )
{
return new std::list<LabelPosition*>();
}

return prob->getSolution( displayAll );
}
Expand Down
1 change: 1 addition & 0 deletions src/core/qgslabelingenginev2.cpp
Expand Up @@ -353,6 +353,7 @@ QgsLabelFeature::QgsLabelFeature( QgsFeatureId id, GEOSGeometry* geometry, const
, mPriority( -1 )
, mHasFixedPosition( false )
, mHasFixedAngle( false )
, mFixedAngle( 0 )
, mHasFixedQuadrant( false )
, mDistLabel( 0 )
, mRepeatDistance( 0 )
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsrendercontext.cpp
Expand Up @@ -31,6 +31,7 @@ QgsRenderContext::QgsRenderContext()
, mRasterScaleFactor( 1.0 )
, mRendererScale( 1.0 )
, mLabelingEngine( NULL )
, mLabelingEngine2( 0 )
, mShowSelection( true )
, mUseRenderingOptimization( true )
, mGeometry( 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerlabelprovider.cpp
Expand Up @@ -472,7 +472,7 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition* label, Q
{

// TODO: optimize access :)
QgsTextLabelFeature* lf = dynamic_cast<QgsTextLabelFeature*>( label->getFeaturePart()->feature() );
QgsTextLabelFeature* lf = static_cast<QgsTextLabelFeature*>( label->getFeaturePart()->feature() );
QString txt = lf->text( label->getPartId() );
QFontMetricsF* labelfm = lf->labelFontMetrics();

Expand Down
1 change: 1 addition & 0 deletions src/gui/auth/qgsauthauthoritieseditor.cpp
Expand Up @@ -46,6 +46,7 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
, mRootCaSecItem( 0 )
, mFileCaSecItem( 0 )
, mDbCaSecItem( 0 )
, mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
, mUtilitiesMenu( 0 )
, mActionDefaultTrustPolicy( 0 )
, mActionShowTrustedCAs( 0 )
Expand Down
7 changes: 4 additions & 3 deletions src/gui/auth/qgsauthconfigedit.cpp
Expand Up @@ -355,9 +355,10 @@ void QgsAuthConfigEdit::validateAuth()
{
QgsDebugMsg( QString( "Cast to edit widget FAILED" ) );
}

authok = authok && editWidget->validateConfig();

else
{
authok = authok && editWidget->validateConfig();
}
authok = authok && authCfgEdit->validate();

buttonBox->button( QDialogButtonBox::Save )->setEnabled( authok );
Expand Down
2 changes: 0 additions & 2 deletions src/gui/auth/qgsautheditorwidgets.h
Expand Up @@ -42,8 +42,6 @@ class GUI_EXPORT QgsAuthMethodPlugins : public QDialog, private Ui::QgsAuthMetho

private:
void setupTable();
QVBoxLayout *mAuthNotifyLayout;
QLabel *mAuthNotify;
};


Expand Down
2 changes: 1 addition & 1 deletion src/gui/auth/qgsauthguiutils.cpp
Expand Up @@ -86,7 +86,7 @@ void QgsAuthGuiUtils::setMasterPassword( QgsMessageBar *msgbar, int timeout )
QgsMessageBar::INFO, timeout );
return;
}
QgsAuthManager::instance()->setMasterPassword( true );
( void )QgsAuthManager::instance()->setMasterPassword( true );
}

void QgsAuthGuiUtils::clearCachedMasterPassword( QgsMessageBar *msgbar, int timeout )
Expand Down
1 change: 0 additions & 1 deletion src/gui/auth/qgsauthsslconfigwidget.h
Expand Up @@ -163,7 +163,6 @@ class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSsl
QSslCertificate mCert;
QList<QSslCertificate> mConnectionCAs;

QTreeWidgetItem *mRootItem;
QTreeWidgetItem *mProtocolItem;
QComboBox *mProtocolCmbBx;
QTreeWidgetItem *mIgnoreErrorsItem;
Expand Down
Expand Up @@ -297,6 +297,11 @@ void QgsGeometrySelfIntersectionCheck::fixError( QgsGeometryCheckError* error, i
changes[newFeature.id()].append( Change( ChangeFeature, ChangeAdded ) );
}
}
else
{
delete ringGeom1;
delete ringGeom2;
}
error->setFixed( method );
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp
Expand Up @@ -19,7 +19,10 @@
#include "ui/qgsgeometrycheckerdialog.h"

QgsGeometryCheckerPlugin::QgsGeometryCheckerPlugin( QgisInterface* iface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ), mIface( iface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mIface( iface )
, mDialog( 0 )
, mMenuAction( 0 )
{
}

Expand Down
Expand Up @@ -333,6 +333,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
{
// QgsGeometry above takes ownership of geometry and deletes it when it goes out of scope
delete geometry;
geometry = 0;
}

if ( ui.radioButtonError->isChecked() || current || error->status() == QgsGeometryCheckError::StatusFixed )
Expand All @@ -345,7 +346,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
mCurrentRubberBands.append( pointRubberBand );
errorPositions.append( pos );
}
else if ( ui.radioButtonFeature->isChecked() )
else if ( ui.radioButtonFeature->isChecked() && geometry )
{
QgsRectangle geomextent = mIface->mapCanvas()->mapSettings().layerExtentToOutputExtent( mFeaturePool->getLayer(), geometry->boundingBox() );
if ( totextent.isEmpty() )
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/geometry_snapper/qgsgeometrysnapperplugin.cpp
Expand Up @@ -18,8 +18,10 @@
#include "qgisinterface.h"

QgsGeometrySnapperPlugin::QgsGeometrySnapperPlugin( QgisInterface* iface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ),
mIface( iface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mIface( iface )
, mDialog( 0 )
, mMenuAction( 0 )
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlnewconnection.cpp
Expand Up @@ -212,7 +212,7 @@ void QgsMssqlNewConnection::listDatabases()
{
QSqlQuery query = QSqlQuery( db );
query.setForwardOnly( true );
query.exec( queryStr );
( void )query.exec( queryStr );

if ( !txtService->text().isEmpty() )
{
Expand Down
1 change: 1 addition & 0 deletions src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -1675,6 +1675,7 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
: mNAM( new QgsNetworkAccessManager )
, mAuth( auth )
, mEventLoop( new QEventLoop )
, mCacheReply( 0 )
, mCachedData( cachedData )
, mWcsVersion( wcsVersion )
, mCachedError( cachedError )
Expand Down

0 comments on commit c5f464b

Please sign in to comment.