Skip to content
Permalink
Browse files

Fix crash when editing marker through symbol manager (fix #13077)

  • Loading branch information
nyalldawson committed Jul 6, 2015
1 parent 4cf3825 commit e4aa1c596ec96e2d28c5782f4455206137c6eabf
@@ -57,24 +57,24 @@ class GUI_EXPORT QgsRendererV2Widget : public QWidget
QAction* mCopyAction;
QAction* mPasteAction;

/**Subclasses may provide the capability of changing multiple symbols at once by implementing the following two methods
/** Subclasses may provide the capability of changing multiple symbols at once by implementing the following two methods
and by connecting the slot contextMenuViewCategories(const QPoint&)*/
virtual QList<QgsSymbolV2*> selectedSymbols() { return QList<QgsSymbolV2*>(); }
virtual void refreshSymbolView() {}

protected slots:
void contextMenuViewCategories( const QPoint& p );
/**Change color of selected symbols*/
/** Change color of selected symbols*/
void changeSymbolColor();
/**Change opacity of selected symbols*/
/** Change opacity of selected symbols*/
void changeSymbolTransparency();
/**Change units mm/map units of selected symbols*/
/** Change units mm/map units of selected symbols*/
void changeSymbolUnit();
/**Change line widths of selected symbols*/
/** Change line widths of selected symbols*/
void changeSymbolWidth();
/**Change marker sizes of selected symbols*/
/** Change marker sizes of selected symbols*/
void changeSymbolSize();
/**Change marker angles of selected symbols*/
/** Change marker angles of selected symbols*/
void changeSymbolAngle();

virtual void copy() {}
@@ -173,7 +173,7 @@ class GUI_EXPORT QgsDataDefinedSizeDialog : public QgsDataDefinedValueDialog
: QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
{
init( tr( "Symbol size" ) );
if ( symbolList.length() )
if ( symbolList.length() && mLayer )
mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList[0] ) ) );
}

@@ -82,13 +82,20 @@ QgsSizeScaleWidget::QgsSizeScaleWidget( const QgsVectorLayer * layer, const QgsM
: mSymbol( symbol )
// we just use the minimumValue and maximumValue from the layer, unfortunately they are
// non const, so we get the layer from the registry instead
, mLayer( dynamic_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( layer->id() ) ) )
, mLayer( layer ? dynamic_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( layer->id() ) ) : 0 )
{
setupUi( this );
setWindowFlags( Qt::WindowStaysOnTopHint );

mLayerTreeLayer = new QgsLayerTreeLayer( mLayer );
mRoot.addChildNode( mLayerTreeLayer ); // takes ownership
if ( mLayer )
{
mLayerTreeLayer = new QgsLayerTreeLayer( mLayer );
mRoot.addChildNode( mLayerTreeLayer ); // takes ownership
}
else
{
mLayerTreeLayer = 0;
}

treeView->setModel( &mPreviewList );
treeView->setItemDelegate( new ItemDelegate( &mPreviewList ) );
@@ -104,7 +111,10 @@ QgsSizeScaleWidget::QgsSizeScaleWidget( const QgsVectorLayer * layer, const QgsM
connect( computeValuesButton, SIGNAL( clicked() ), computeValuesButton, SLOT( showMenu() ) );

//mExpressionWidget->setFilters( QgsFieldProxyModel::Numeric | QgsFieldProxyModel::Date );
mExpressionWidget->setLayer( mLayer );
if ( mLayer )
{
mExpressionWidget->setLayer( mLayer );
}

scaleMethodComboBox->addItem( tr( "Flannery" ), int( QgsScaleExpression::Flannery ) );
scaleMethodComboBox->addItem( tr( "Surface" ), int( QgsScaleExpression::Area ) );
@@ -153,7 +163,7 @@ QgsScaleExpression *QgsSizeScaleWidget::createExpression() const

void QgsSizeScaleWidget::updatePreview()
{
if ( !mSymbol )
if ( !mSymbol || !mLayer )
return;

QScopedPointer<QgsScaleExpression> expr( createExpression() );
@@ -193,6 +203,9 @@ void QgsSizeScaleWidget::updatePreview()

void QgsSizeScaleWidget::computeFromLayerTriggered()
{
if ( !mLayer )
return;

QgsExpression expression( mExpressionWidget->currentField() );
if ( ! expression.prepare( mLayer->pendingFields() ) )
return;
@@ -338,7 +338,8 @@ QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( const Qg
//make a temporary symbol for the size assistant preview
mAssistantPreviewSymbol = new QgsMarkerSymbolV2();

mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
if ( mVectorLayer )
mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );

QSize size = lstNames->iconSize();
QStringList names;
@@ -1538,7 +1539,8 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVecto

//make a temporary symbol for the size assistant preview
mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
if ( mVectorLayer )
mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
}

QgsSvgMarkerSymbolLayerV2Widget::~QgsSvgMarkerSymbolLayerV2Widget()
@@ -2504,7 +2506,8 @@ QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( const QgsVec
//make a temporary symbol for the size assistant preview
mAssistantPreviewSymbol = new QgsMarkerSymbolV2();

mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
if ( mVectorLayer )
mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );

connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );

0 comments on commit e4aa1c5

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