Skip to content
Permalink
Browse files

Fix crashes in styling dock when dealing with WMTS / XYZ

  • Loading branch information
wonder-sk committed Sep 5, 2016
1 parent 2d9e72d commit beb5d0034f4992ac497e9eeac8b47145375181e9
Showing with 32 additions and 17 deletions.
  1. +25 −17 src/app/qgslayerstylingwidget.cpp
  2. +7 −0 src/gui/raster/qgsrastertransparencywidget.cpp
@@ -38,6 +38,7 @@
#include "qgsrenderer.h"
#include "qgsrendererregistry.h"
#include "qgsmaplayerregistry.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterlayer.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerstylemanagerwidget.h"
@@ -171,10 +172,14 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
transparencyItem->setToolTip( tr( "Transparency" ) );
transparencyItem->setData( Qt::UserRole, RasterTransparency );
mOptionsListWidget->addItem( transparencyItem );
QListWidgetItem* histogramItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/histogram.png" ), QString() );
histogramItem->setData( Qt::UserRole, RasterHistogram );
mOptionsListWidget->addItem( histogramItem );
histogramItem->setToolTip( tr( "Histogram" ) );

if ( static_cast<QgsRasterLayer*>( layer )->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
QListWidgetItem* histogramItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/histogram.png" ), QString() );
histogramItem->setData( Qt::UserRole, RasterHistogram );
mOptionsListWidget->addItem( histogramItem );
histogramItem->setToolTip( tr( "Histogram" ) );
}
}

Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mPageFactories )
@@ -392,21 +397,24 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
}
case 2: // Histogram
{
if ( mRasterStyleWidget )
if ( rlayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
mRasterStyleWidget->deleteLater();
delete mRasterStyleWidget;
if ( mRasterStyleWidget )
{
mRasterStyleWidget->deleteLater();
delete mRasterStyleWidget;
}
mRasterStyleWidget = new QgsRendererRasterPropertiesWidget( rlayer, mMapCanvas, mWidgetStack );
mRasterStyleWidget->syncToLayer( rlayer );
connect( mRasterStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );

QgsRasterHistogramWidget* widget = new QgsRasterHistogramWidget( rlayer, mWidgetStack );
connect( widget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
QString name = mRasterStyleWidget->currentRenderWidget()->renderer()->type();
widget->setRendererWidget( name, mRasterStyleWidget->currentRenderWidget() );

mWidgetStack->addMainPanel( widget );
}
mRasterStyleWidget = new QgsRendererRasterPropertiesWidget( rlayer, mMapCanvas, mWidgetStack );
mRasterStyleWidget->syncToLayer( rlayer );
connect( mRasterStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );

QgsRasterHistogramWidget* widget = new QgsRasterHistogramWidget( rlayer, mWidgetStack );
connect( widget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
QString name = mRasterStyleWidget->currentRenderWidget()->renderer()->type();
widget->setRendererWidget( name, mRasterStyleWidget->currentRenderWidget() );

mWidgetStack->addMainPanel( widget );
break;
}
default:
@@ -76,6 +76,13 @@ void QgsRasterTransparencyWidget::syncToLayer()
QgsRasterRenderer* renderer = mRasterLayer->renderer();
if ( provider )
{
if ( provider->dataType( 1 ) == Qgis::ARGB32
|| provider->dataType( 1 ) == Qgis::ARGB32_Premultiplied )
{
gboxNoDataValue->setEnabled( false );
gboxCustomTransparency->setEnabled( false );
}

cboxTransparencyBand->addItem( tr( "None" ), -1 );
int nBands = provider->bandCount();
QString bandName;

0 comments on commit beb5d00

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