Index: src/app/qgssnappingdialog.cpp =================================================================== --- src/app/qgssnappingdialog.cpp (Revision 14696) +++ src/app/qgssnappingdialog.cpp (Arbeitskopie) @@ -27,6 +27,7 @@ #include #include #include +#include class QgsSnappingDock : public QDockWidget @@ -63,9 +64,9 @@ else { connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) ); + connect( mButtonBox->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), this, SLOT( apply() ) ); } - connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( update() ) ); - connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( update() ) ); + connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( connectUpdate( QgsMapLayer *) ) ); update(); @@ -106,8 +107,8 @@ QSettings myQsettings; bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); - double defaultSnapppingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble(); - int defaultSnapppingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt(); + double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble(); + int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt(); QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString(); int defaultSnappingStringIdx = 0; @@ -133,9 +134,12 @@ mLayerTreeWidget->clear(); - for ( int i = 0; i < mMapCanvas->layerCount(); ++i ) + QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); + int a = mapLayers.count(); + QMap< QString, QgsMapLayer *>::iterator it; + for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it ) { - QgsVectorLayer *currentVectorLayer = qobject_cast( mMapCanvas->layer( i ) ); + QgsVectorLayer *currentVectorLayer = qobject_cast( it.value() ); if ( !currentVectorLayer ) continue; @@ -160,7 +164,7 @@ QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget ); QDoubleValidator *validator = new QDoubleValidator( leTolerance ); leTolerance->setValidator( validator ); - leTolerance->setText( QString::number( defaultSnapppingTolerance, 'f' ) ); + leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) ); mLayerTreeWidget->setItemWidget( item, 3, leTolerance ); @@ -168,7 +172,7 @@ QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget ); cbxUnits->insertItem( 0, tr( "map units" ) ); cbxUnits->insertItem( 1, tr( "pixels" ) ); - cbxUnits->setCurrentIndex( defaultSnapppingUnit ); + cbxUnits->setCurrentIndex( defaultSnappingUnit ); mLayerTreeWidget->setItemWidget( item, 4, cbxUnits ); int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() ); @@ -262,3 +266,10 @@ else QDialog::show(); } + + +void QgsSnappingDialog::connectUpdate(QgsMapLayer * theMapLayer) +{ + connect( theMapLayer,SIGNAL( destroyed() ),this,SLOT( update() ) ); + update(); +} Index: src/app/qgssnappingdialog.h =================================================================== --- src/app/qgssnappingdialog.h (Revision 14696) +++ src/app/qgssnappingdialog.h (Arbeitskopie) @@ -18,6 +18,7 @@ #ifndef QGSSNAPPINGDIALOG_H #define QGSSNAPPINGDIALOG_H +#include "qgsmaplayer.h" #include "ui_qgssnappingdialogbase.h" class QDockWidget; @@ -41,12 +42,12 @@ //! apply the changes void apply(); - //! update the Dialog - void update(); - //! show dialog or dock void show(); + //! connect to the layers destroyed() and then update() + void connectUpdate(QgsMapLayer* theMapLayer); + protected: /**Constructor @param canvas pointer to the map canvas (for detecting which vector layers are loaded @@ -67,6 +68,10 @@ QgsMapCanvas* mMapCanvas; QDockWidget *mDock; + + private slots: + //! update the Dialog + void update(); }; #endif Index: src/app/qgsprojectproperties.h =================================================================== --- src/app/qgsprojectproperties.h (Revision 14696) +++ src/app/qgsprojectproperties.h (Arbeitskopie) @@ -21,7 +21,6 @@ #include "ui_qgsprojectpropertiesbase.h" #include "qgis.h" #include "qgisgui.h" -#include "qgssnappingdialog.h" #include "qgscontexthelp.h" class QgsMapCanvas; Index: src/core/qgsmaplayerregistry.cpp =================================================================== --- src/core/qgsmaplayerregistry.cpp (Revision 14696) +++ src/core/qgsmaplayerregistry.cpp (Arbeitskopie) @@ -111,6 +111,7 @@ { emit layerWillBeRemoved( it.key() ); delete it.value(); // delete the map layer + mMapLayers.remove( it.key() ); } mMapLayers.clear(); Index: src/ui/qgssnappingdialogbase.ui =================================================================== --- src/ui/qgssnappingdialogbase.ui (Revision 14696) +++ src/ui/qgssnappingdialogbase.ui (Arbeitskopie) @@ -30,7 +30,7 @@ - + @@ -61,7 +61,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok