Skip to content

Commit c5f464b

Browse files
committed
Coverity fixes
1 parent 7c03619 commit c5f464b

20 files changed

+49
-27
lines changed

src/app/nodetool/qgsmaptoolnodetool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
3636
, mNodeEditor( 0 )
3737
, mMoving( true )
3838
, mSelectAnother( false )
39+
, mAnother( 0 )
3940
, mSelectionRubberBand( 0 )
4041
, mRect( 0 )
4142
, mIsPoint( false )

src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9555,7 +9555,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
95559555
mActionCopyFeatures->setEnabled( layerHasSelection );
95569556
mActionFeatureAction->setEnabled( layerHasActions );
95579557

9558-
if ( !isEditable && mMapCanvas->mapTool()
9558+
if ( !isEditable && mMapCanvas && mMapCanvas->mapTool()
95599559
&& mMapCanvas->mapTool()->isEditTool() && !mSaveRollbackInProgress )
95609560
{
95619561
mMapCanvas->setMapTool( mNonEditMapTool );

src/app/qgsattributetabledialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )
744744
{
745745
str = query;
746746
}
747-
else
747+
else if ( mCurrentSearchWidgetWrapper )
748748
{
749749
str = mCurrentSearchWidgetWrapper->expression();
750750
}

src/app/qgsvariantdelegate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void QgsVariantDelegate::setModelData( QWidget* editor, QAbstractItemModel* mode
189189
value = text.at( 0 );
190190
break;
191191
case QVariant::Color:
192-
mColorExp.exactMatch( text );
192+
( void )mColorExp.exactMatch( text );
193193
value = QColor( qMin( mColorExp.cap( 1 ).toInt(), 255 ),
194194
qMin( mColorExp.cap( 2 ).toInt(), 255 ),
195195
qMin( mColorExp.cap( 3 ).toInt(), 255 ),
@@ -212,16 +212,16 @@ void QgsVariantDelegate::setModelData( QWidget* editor, QAbstractItemModel* mode
212212
}
213213
break;
214214
case QVariant::Point:
215-
mPointExp.exactMatch( text );
215+
( void )mPointExp.exactMatch( text );
216216
value = QPoint( mPointExp.cap( 1 ).toInt(), mPointExp.cap( 2 ).toInt() );
217217
break;
218218
case QVariant::Rect:
219-
mRectExp.exactMatch( text );
219+
( void )mRectExp.exactMatch( text );
220220
value = QRect( mRectExp.cap( 1 ).toInt(), mRectExp.cap( 2 ).toInt(),
221221
mRectExp.cap( 3 ).toInt(), mRectExp.cap( 4 ).toInt() );
222222
break;
223223
case QVariant::Size:
224-
mSizeExp.exactMatch( text );
224+
( void )mSizeExp.exactMatch( text );
225225
value = QSize( mSizeExp.cap( 1 ).toInt(), mSizeExp.cap( 2 ).toInt() );
226226
break;
227227
case QVariant::StringList:

src/core/auth/qgsauthmanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ QSqlDatabase QgsAuthManager::authDbConnection() const
8484
authdb = QSqlDatabase::database( connectionname );
8585
}
8686
if ( !authdb.isOpen() )
87-
authdb.open();
87+
( void )authdb.open();
8888

8989
return authdb;
9090
}
@@ -3230,7 +3230,7 @@ bool QgsAuthManager::authDbQuery( QSqlQuery *query ) const
32303230
return false;
32313231

32323232
query->setForwardOnly( true );
3233-
query->exec();
3233+
( void )query->exec();
32343234

32353235
if ( query->lastError().isValid() )
32363236
{

src/core/pal/pal.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "labelposition.h"
4444
#include "problem.h"
4545
#include "pointset.h"
46+
#include "internalexception.h"
4647
#include "util.h"
4748
#include <QTime>
4849
#include <cstdarg>
@@ -586,12 +587,19 @@ namespace pal
586587

587588
prob->reduce();
588589

589-
if ( searchMethod == FALP )
590-
prob->init_sol_falp();
591-
else if ( searchMethod == CHAIN )
592-
prob->chain_search();
593-
else
594-
prob->popmusic();
590+
try
591+
{
592+
if ( searchMethod == FALP )
593+
prob->init_sol_falp();
594+
else if ( searchMethod == CHAIN )
595+
prob->chain_search();
596+
else
597+
prob->popmusic();
598+
}
599+
catch ( InternalException::Empty )
600+
{
601+
return new std::list<LabelPosition*>();
602+
}
595603

596604
return prob->getSolution( displayAll );
597605
}

src/core/qgslabelingenginev2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ QgsLabelFeature::QgsLabelFeature( QgsFeatureId id, GEOSGeometry* geometry, const
353353
, mPriority( -1 )
354354
, mHasFixedPosition( false )
355355
, mHasFixedAngle( false )
356+
, mFixedAngle( 0 )
356357
, mHasFixedQuadrant( false )
357358
, mDistLabel( 0 )
358359
, mRepeatDistance( 0 )

src/core/qgsrendercontext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ QgsRenderContext::QgsRenderContext()
3131
, mRasterScaleFactor( 1.0 )
3232
, mRendererScale( 1.0 )
3333
, mLabelingEngine( NULL )
34+
, mLabelingEngine2( 0 )
3435
, mShowSelection( true )
3536
, mUseRenderingOptimization( true )
3637
, mGeometry( 0 )

src/core/qgsvectorlayerlabelprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition* label, Q
472472
{
473473

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

src/gui/auth/qgsauthauthoritieseditor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
4646
, mRootCaSecItem( 0 )
4747
, mFileCaSecItem( 0 )
4848
, mDbCaSecItem( 0 )
49+
, mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
4950
, mUtilitiesMenu( 0 )
5051
, mActionDefaultTrustPolicy( 0 )
5152
, mActionShowTrustedCAs( 0 )

src/gui/auth/qgsauthconfigedit.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ void QgsAuthConfigEdit::validateAuth()
355355
{
356356
QgsDebugMsg( QString( "Cast to edit widget FAILED" ) );
357357
}
358-
359-
authok = authok && editWidget->validateConfig();
360-
358+
else
359+
{
360+
authok = authok && editWidget->validateConfig();
361+
}
361362
authok = authok && authCfgEdit->validate();
362363

363364
buttonBox->button( QDialogButtonBox::Save )->setEnabled( authok );

src/gui/auth/qgsautheditorwidgets.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ class GUI_EXPORT QgsAuthMethodPlugins : public QDialog, private Ui::QgsAuthMetho
4242

4343
private:
4444
void setupTable();
45-
QVBoxLayout *mAuthNotifyLayout;
46-
QLabel *mAuthNotify;
4745
};
4846

4947

src/gui/auth/qgsauthguiutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void QgsAuthGuiUtils::setMasterPassword( QgsMessageBar *msgbar, int timeout )
8686
QgsMessageBar::INFO, timeout );
8787
return;
8888
}
89-
QgsAuthManager::instance()->setMasterPassword( true );
89+
( void )QgsAuthManager::instance()->setMasterPassword( true );
9090
}
9191

9292
void QgsAuthGuiUtils::clearCachedMasterPassword( QgsMessageBar *msgbar, int timeout )

src/gui/auth/qgsauthsslconfigwidget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSsl
163163
QSslCertificate mCert;
164164
QList<QSslCertificate> mConnectionCAs;
165165

166-
QTreeWidgetItem *mRootItem;
167166
QTreeWidgetItem *mProtocolItem;
168167
QComboBox *mProtocolCmbBx;
169168
QTreeWidgetItem *mIgnoreErrorsItem;

src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ void QgsGeometrySelfIntersectionCheck::fixError( QgsGeometryCheckError* error, i
297297
changes[newFeature.id()].append( Change( ChangeFeature, ChangeAdded ) );
298298
}
299299
}
300+
else
301+
{
302+
delete ringGeom1;
303+
delete ringGeom2;
304+
}
300305
error->setFixed( method );
301306
}
302307
else

src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
#include "ui/qgsgeometrycheckerdialog.h"
2020

2121
QgsGeometryCheckerPlugin::QgsGeometryCheckerPlugin( QgisInterface* iface )
22-
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ), mIface( iface )
22+
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
23+
, mIface( iface )
24+
, mDialog( 0 )
25+
, mMenuAction( 0 )
2326
{
2427
}
2528

src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
333333
{
334334
// QgsGeometry above takes ownership of geometry and deletes it when it goes out of scope
335335
delete geometry;
336+
geometry = 0;
336337
}
337338

338339
if ( ui.radioButtonError->isChecked() || current || error->status() == QgsGeometryCheckError::StatusFixed )
@@ -345,7 +346,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
345346
mCurrentRubberBands.append( pointRubberBand );
346347
errorPositions.append( pos );
347348
}
348-
else if ( ui.radioButtonFeature->isChecked() )
349+
else if ( ui.radioButtonFeature->isChecked() && geometry )
349350
{
350351
QgsRectangle geomextent = mIface->mapCanvas()->mapSettings().layerExtentToOutputExtent( mFeaturePool->getLayer(), geometry->boundingBox() );
351352
if ( totextent.isEmpty() )

src/plugins/geometry_snapper/qgsgeometrysnapperplugin.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
#include "qgisinterface.h"
1919

2020
QgsGeometrySnapperPlugin::QgsGeometrySnapperPlugin( QgisInterface* iface )
21-
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ),
22-
mIface( iface )
21+
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
22+
, mIface( iface )
23+
, mDialog( 0 )
24+
, mMenuAction( 0 )
2325
{
2426
}
2527

src/providers/mssql/qgsmssqlnewconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void QgsMssqlNewConnection::listDatabases()
212212
{
213213
QSqlQuery query = QSqlQuery( db );
214214
query.setForwardOnly( true );
215-
query.exec( queryStr );
215+
( void )query.exec( queryStr );
216216

217217
if ( !txtService->text().isEmpty() )
218218
{

src/providers/wcs/qgswcsprovider.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
16751675
: mNAM( new QgsNetworkAccessManager )
16761676
, mAuth( auth )
16771677
, mEventLoop( new QEventLoop )
1678+
, mCacheReply( 0 )
16781679
, mCachedData( cachedData )
16791680
, mWcsVersion( wcsVersion )
16801681
, mCachedError( cachedError )

0 commit comments

Comments
 (0)