Skip to content

Commit

Permalink
[gui] Fix crash when loading a vector layer style, due to lack of che…
Browse files Browse the repository at this point in the history
…cks for removed deprecated labels tab
  • Loading branch information
dakcarto committed Sep 2, 2013
1 parent 2d63dcf commit a2a2d7a
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

QgsVectorLayerProperties::~QgsVectorLayerProperties()
{
if ( mOptsPage_LabelsOld && layer->hasGeometryType() )
if ( mOptsPage_LabelsOld && labelDialog && layer->hasGeometryType() )
{
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
}
Expand Down Expand Up @@ -395,24 +395,29 @@ void QgsVectorLayerProperties::syncToLayer( void )
// load appropriate symbology page (V1 or V2)
updateSymbologyPage();

actionDialog->init();

// reset fields in label dialog
layer->label()->setFields( layer->pendingFields() );

actionDialog->init();

if ( layer->hasGeometryType() )
{
labelingDialog->init();
labelDialog->init();
}

labelCheckBox->setChecked( layer->hasLabelsEnabled() );
labelOptionsFrame->setEnabled( layer->hasLabelsEnabled() );
if ( mOptsPage_LabelsOld )
{
if ( labelDialog && layer->hasGeometryType() )
{
labelDialog->init();
}
labelCheckBox->setChecked( layer->hasLabelsEnabled() );
labelOptionsFrame->setEnabled( layer->hasLabelsEnabled() );
QObject::connect( labelCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( enableLabelOptions( bool ) ) );
}

mFieldsPropertiesDialog->init();

QObject::connect( labelCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( enableLabelOptions( bool ) ) );

// delete deprecated labels tab if not already used by project
// NOTE: this is not ideal, but a quick fix for QGIS 2.0 release
bool ok;
Expand All @@ -421,7 +426,10 @@ void QgsVectorLayerProperties::syncToLayer( void )
{
if ( mOptsPage_LabelsOld )
{
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
if ( labelDialog )
{
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
}
delete mOptsPage_LabelsOld;
mOptsPage_LabelsOld = 0;
}
Expand Down Expand Up @@ -479,11 +487,14 @@ void QgsVectorLayerProperties::apply()
if ( mOptsPage_LabelsOld )
{
if ( labelDialog )
{
labelDialog->apply();
}
layer->enableLabels( labelCheckBox->isChecked() );
layer->setLayerName( mLayerOrigNameLineEdit->text() );
}

layer->setLayerName( mLayerOrigNameLineEdit->text() );

// Apply fields settings
mFieldsPropertiesDialog->apply();

Expand Down Expand Up @@ -728,6 +739,8 @@ void QgsVectorLayerProperties::on_pbnLoadStyle_clicked()
QFileInfo myFI( myFileName );
QString myPath = myFI.path();
myQSettings.setValue( "style/lastStyleDir", myPath );

activateWindow(); // set focus back to properties dialog
}


Expand Down

0 comments on commit a2a2d7a

Please sign in to comment.