Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash when editing graduated symbol in style dock
Fixes #18909

(cherry-picked from 9887508)
  • Loading branch information
nyalldawson committed Jul 20, 2018
1 parent 39f23eb commit 7886c91
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Expand Up @@ -28,6 +28,7 @@ Symbol selector widget that can be used to select and build a symbol
%End
public:


QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent /TransferThis/ = 0 );
%Docstring
Symbol selector widget that can be used to select and build a symbol
Expand Down
2 changes: 2 additions & 0 deletions src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp
Expand Up @@ -548,6 +548,8 @@ void QgsCategorizedSymbolRendererWidget::changeCategorizedSymbol()
std::unique_ptr<QgsSymbol> newSymbol( mCategorizedSymbol->clone() );
if ( panel && panel->dockMode() )
{
// bit tricky here - the widget doesn't take ownership of the symbol. So we need it to last for the duration of the
// panel's existence. Accordingly, just kinda give it ownership here, and clean up in cleanUpSymbolSelector
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.release(), mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
Expand Down
4 changes: 3 additions & 1 deletion src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
Expand Up @@ -977,7 +977,9 @@ void QgsGraduatedSymbolRendererWidget::changeRangeSymbol( int rangeIdx )
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.get(), mStyle, mLayer, panel );
// bit tricky here - the widget doesn't take ownership of the symbol. So we need it to last for the duration of the
// panel's existence. Accordingly, just kinda give it ownership here, and clean up in cleanUpSymbolSelector
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.release(), mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/symbology/qgssymbolselectordialog.h
Expand Up @@ -93,6 +93,8 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs

public:

// TODO QGIS 4.0 - transfer ownership of symbol to widget!

/**
* Symbol selector widget that can be used to select and build a symbol
* \param symbol The symbol to load into the widget as a start point.
Expand Down

0 comments on commit 7886c91

Please sign in to comment.