Skip to content
Permalink
Browse files

Fix coverity null pointer dereference warnings

  • Loading branch information
nyalldawson committed Dec 5, 2017
1 parent 75c9980 commit fa5a8311d1f22d1fc16be619a369e1a5c5d80092
@@ -101,7 +101,7 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap &parameters
multiStepFeedback.setCurrentStep( i );
i++;

feedback->pushInfo( QObject::tr( "Packaging layer %1/%2: %3" ).arg( i ).arg( layers.count() ).arg( layer->name() ) );
feedback->pushInfo( QObject::tr( "Packaging layer %1/%2: %3" ).arg( i ).arg( layers.count() ).arg( layer ? layer->name() : QString() ) );

if ( !layer )
{
@@ -29,6 +29,8 @@ QgsLayoutLabelWidget::QgsLayoutLabelWidget( QgsLayoutItemLabel *label )
: QgsLayoutItemBaseWidget( nullptr, label )
, mLabel( label )
{
Q_ASSERT( mLabel );

setupUi( this );
connect( mHtmlCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutLabelWidget::mHtmlCheckBox_stateChanged );
connect( mTextEdit, &QPlainTextEdit::textChanged, this, &QgsLayoutLabelWidget::mTextEdit_textChanged );
@@ -56,11 +58,8 @@ QgsLayoutLabelWidget::QgsLayoutLabelWidget( QgsLayoutItemLabel *label )
mMarginXDoubleSpinBox->setClearValue( 0.0 );
mMarginYDoubleSpinBox->setClearValue( 0.0 );

if ( mLabel )
{
setGuiElementValues();
connect( mLabel, &QgsLayoutObject::changed, this, &QgsLayoutLabelWidget::setGuiElementValues );
}
setGuiElementValues();
connect( mLabel, &QgsLayoutObject::changed, this, &QgsLayoutLabelWidget::setGuiElementValues );

connect( mFontButton, &QgsFontButton::changed, this, &QgsLayoutLabelWidget::fontChanged );
connect( mJustifyRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::justifyClicked );
@@ -61,6 +61,8 @@ QgsLayoutLegendWidget::QgsLayoutLegendWidget( QgsLayoutItemLegend *legend )
: QgsLayoutItemBaseWidget( nullptr, legend )
, mLegend( legend )
{
Q_ASSERT( mLegend );

setupUi( this );
connect( mWrapCharLineEdit, &QLineEdit::textChanged, this, &QgsLayoutLegendWidget::mWrapCharLineEdit_textChanged );
connect( mTitleLineEdit, &QLineEdit::textChanged, this, &QgsLayoutLegendWidget::mTitleLineEdit_textChanged );
@@ -120,8 +122,7 @@ QgsLayoutLegendWidget::QgsLayoutLegendWidget( QgsLayoutItemLegend *legend )
mRasterStrokeColorButton->setAllowOpacity( true );
mRasterStrokeColorButton->setContext( QStringLiteral( "composer " ) );

if ( legend )
mMapComboBox->setCurrentLayout( legend->layout() );
mMapComboBox->setCurrentLayout( legend->layout() );
mMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
connect( mMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutLegendWidget::composerMapChanged );

@@ -131,18 +132,15 @@ QgsLayoutLegendWidget::QgsLayoutLegendWidget( QgsLayoutItemLegend *legend )

mItemTreeView->setHeaderHidden( true );

if ( legend )
{
mItemTreeView->setModel( legend->model() );
mItemTreeView->setMenuProvider( new QgsLayoutLegendMenuProvider( mItemTreeView, this ) );
connect( legend, &QgsLayoutObject::changed, this, &QgsLayoutLegendWidget::setGuiElements );
mItemTreeView->setModel( legend->model() );
mItemTreeView->setMenuProvider( new QgsLayoutLegendMenuProvider( mItemTreeView, this ) );
connect( legend, &QgsLayoutObject::changed, this, &QgsLayoutLegendWidget::setGuiElements );

#if 0 //TODO
// connect atlas state to the filter legend by atlas checkbox
connect( &legend->composition()->atlasComposition(), &QgsAtlasComposition::toggled, this, &QgsLayoutLegendWidget::updateFilterLegendByAtlasButton );
connect( &legend->composition()->atlasComposition(), &QgsAtlasComposition::coverageLayerChanged, this, &QgsLayoutLegendWidget::updateFilterLegendByAtlasButton );
// connect atlas state to the filter legend by atlas checkbox
connect( &legend->composition()->atlasComposition(), &QgsAtlasComposition::toggled, this, &QgsLayoutLegendWidget::updateFilterLegendByAtlasButton );
connect( &legend->composition()->atlasComposition(), &QgsAtlasComposition::coverageLayerChanged, this, &QgsLayoutLegendWidget::updateFilterLegendByAtlasButton );
#endif
}

registerDataDefinedButton( mLegendTitleDDBtn, QgsLayoutObject::LegendTitle );
registerDataDefinedButton( mColumnsDDBtn, QgsLayoutObject::LegendColumnCount );
@@ -35,6 +35,8 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
: QgsLayoutItemBaseWidget( nullptr, item )
, mMapItem( item )
{
Q_ASSERT( mMapItem );

setupUi( this );
connect( mScaleLineEdit, &QLineEdit::editingFinished, this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
connect( mSetToMapCanvasExtentButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked );
@@ -108,24 +110,21 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )

mOverviewFrameMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );

if ( item )
{
connect( item, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
connect( item, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );

#if 0 //TODO
QgsAtlasComposition *atlas = atlasComposition();
if ( atlas )
{
connect( atlas, &QgsAtlasComposition::coverageLayerChanged,
this, &QgsLayoutMapWidget::atlasLayerChanged );
connect( atlas, &QgsAtlasComposition::toggled, this, &QgsLayoutMapWidget::compositionAtlasToggled );
QgsAtlasComposition *atlas = atlasComposition();
if ( atlas )
{
connect( atlas, &QgsAtlasComposition::coverageLayerChanged,
this, &QgsLayoutMapWidget::atlasLayerChanged );
connect( atlas, &QgsAtlasComposition::toggled, this, &QgsLayoutMapWidget::compositionAtlasToggled );

compositionAtlasToggled( atlas->enabled() );
}
#endif
mOverviewFrameMapComboBox->setCurrentLayout( item->layout() );
mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
compositionAtlasToggled( atlas->enabled() );
}
#endif
mOverviewFrameMapComboBox->setCurrentLayout( item->layout() );
mOverviewFrameStyleButton->registerExpressionContextGenerator( item );

connect( mOverviewFrameMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutMapWidget::overviewMapChanged );
connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsLayoutMapWidget::mapCrsChanged );
@@ -25,6 +25,8 @@ QgsLayoutShapeWidget::QgsLayoutShapeWidget( QgsLayoutItemShape *shape )
: QgsLayoutItemBaseWidget( nullptr, shape )
, mShape( shape )
{
Q_ASSERT( mShape );

setupUi( this );
connect( mShapeComboBox, static_cast<void ( QComboBox::* )( const QString & )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutShapeWidget::mShapeComboBox_currentIndexChanged );
connect( mCornerRadiusSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutShapeWidget::mCornerRadiusSpinBox_valueChanged );
@@ -52,11 +54,9 @@ QgsLayoutShapeWidget::QgsLayoutShapeWidget( QgsLayoutItemShape *shape )

blockAllSignals( false );

if ( mShape )
{
connect( mShape, &QgsLayoutObject::changed, this, &QgsLayoutShapeWidget::setGuiElementValues );
mShapeStyleButton->registerExpressionContextGenerator( mShape );
}
connect( mShape, &QgsLayoutObject::changed, this, &QgsLayoutShapeWidget::setGuiElementValues );
mShapeStyleButton->registerExpressionContextGenerator( mShape );

connect( mShapeStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutShapeWidget::symbolChanged );
connect( mRadiusUnitsComboBox, &QgsLayoutUnitsComboBox::changed, this, &QgsLayoutShapeWidget::radiusUnitsChanged );

@@ -143,7 +143,7 @@ void QgsLayoutMultiFrame::recalculateFrameSizes()
}

//at end of frames but there is still content left. Add other pages if ResizeMode ==
if ( mResizeMode != UseExistingFrames )
if ( currentItem && mResizeMode != UseExistingFrames )
{
while ( ( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
{
@@ -301,7 +301,8 @@ bool TestQgsDxfExport::fileContainsText( const QString &path, const QString &tex
{
QStringList searchLines = text.split( '\n' );
QFile file( path );
QVERIFY( file.open( QIODevice::ReadOnly ) );
if ( !file.open( QIODevice::ReadOnly ) )
return false;
QTextStream in( &file );
QString line;
do

0 comments on commit fa5a831

Please sign in to comment.
You can’t perform that action at this time.