Skip to content
Permalink
Browse files

Fix style dock forgets expanded state of rendering group (fix #14864)

Also fix a memory leak
  • Loading branch information
nyalldawson committed Jun 9, 2016
1 parent cb4dacf commit 31c572f0ad93f1cb90d8b9f7d6956090f4661261
@@ -5,7 +5,16 @@ class QgsRendererV2PropertiesDialog : QDialog
%End

public:
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false );

/** Constructor for QgsRendererV2PropertiesDialog.
* @param layer associated layer
* @param style style collection
* @param embedded set to true to indicate that the dialog will be embedded in another widget, rather
* than shown as a dialog by itself
* @param parent parent widget
*/
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false, QWidget* parent /TransferThis/ = nullptr );

~QgsRendererV2PropertiesDialog();

/** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current
@@ -281,7 +281,8 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
{
case 0: // Style
{
mVectorStyleWidget = new QgsRendererV2PropertiesDialog( vlayer, QgsStyleV2::defaultStyle(), true );
mVectorStyleWidget->deleteLater();
mVectorStyleWidget = new QgsRendererV2PropertiesDialog( vlayer, QgsStyleV2::defaultStyle(), true, mWidgetArea );
connect( mVectorStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
mWidgetArea->setWidget( mVectorStyleWidget );
break;
@@ -1300,7 +1300,7 @@ void QgsVectorLayerProperties::updateSymbologyPage()

if ( mLayer->rendererV2() )
{
mRendererDialog = new QgsRendererV2PropertiesDialog( mLayer, QgsStyleV2::defaultStyle(), true );
mRendererDialog = new QgsRendererV2PropertiesDialog( mLayer, QgsStyleV2::defaultStyle(), true, this );
mRendererDialog->setMapCanvas( QgisApp::instance()->mapCanvas() );

connect( mRendererDialog, SIGNAL( layerVariablesChanged() ), this, SLOT( updateVariableEditor() ) );
@@ -79,14 +79,16 @@ static void _initRendererWidgetFunctions()
initialized = true;
}

QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded )
: mLayer( layer )
QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded, QWidget* parent )
: QDialog( parent )
, mLayer( layer )
, mStyle( style )
, mActiveWidget( nullptr )
, mPaintEffect( nullptr )
, mMapCanvas( nullptr )
{
setupUi( this );
mLayerRenderingGroupBox->setSettingGroup( "layerRenderingGroupBox" );

// can be embedded in vector layer properties
if ( embedded )
@@ -378,7 +380,7 @@ void QgsRendererV2PropertiesDialog::changeOrderBy( const QgsFeatureRequest::Orde

void QgsRendererV2PropertiesDialog::updateUIState( bool hidden )
{
groupBox->setHidden( hidden );
mLayerRenderingGroupBox->setHidden( hidden );
cboRenderers->setHidden( hidden );
}

@@ -39,7 +39,15 @@ class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::Qgs
Q_OBJECT

public:
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false );

/** Constructor for QgsRendererV2PropertiesDialog.
* @param layer associated layer
* @param style style collection
* @param embedded set to true to indicate that the dialog will be embedded in another widget, rather
* than shown as a dialog by itself
* @param parent parent widget
*/
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false, QWidget* parent = nullptr );
~QgsRendererV2PropertiesDialog();

/** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current
@@ -6,22 +6,40 @@
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<width>370</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Renderer settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="mainStack">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -49,7 +67,16 @@
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -64,7 +91,7 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<widget class="QgsCollapsibleGroupBox" name="mLayerRenderingGroupBox">
<property name="title">
<string>Layer rendering</string>
</property>

0 comments on commit 31c572f

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