35
35
#include " qgsrubberband.h"
36
36
#include " qgsproject.h"
37
37
#include " qgsvectorlayer.h"
38
+ #include " qgsmaplayerregistry.h"
38
39
39
40
#include < QAction>
40
41
#include < QFileInfo>
@@ -57,7 +58,7 @@ static const QString pluginVersion = QObject::tr( "Version 0.1" );
57
58
* @param theQgisInterFace Pointer to the QGIS interface object
58
59
*/
59
60
QgsGrassPlugin::QgsGrassPlugin ( QgisInterface * theQgisInterFace ):
60
- qGisInterface( theQgisInterFace )
61
+ qGisInterface( theQgisInterFace ), mEdit( NULL ), mTools( NULL )
61
62
{
62
63
/* * Initialize the plugin and set the required attributes */
63
64
pluginNameQString = tr ( " GrassVector" );
@@ -68,6 +69,7 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
68
69
QgsGrassPlugin::~QgsGrassPlugin ()
69
70
{
70
71
if ( mTools ) mTools ->closeTools ();
72
+ if ( mEdit ) mEdit ->closeEdit ();
71
73
QString err = QgsGrass::closeMapset ();
72
74
}
73
75
@@ -411,18 +413,21 @@ void QgsGrassPlugin::edit()
411
413
}
412
414
413
415
mEditAction ->setEnabled ( false );
414
- QgsGrassEdit *ed = new QgsGrassEdit ( qGisInterface, qGisInterface->activeLayer (), false ,
416
+ mEdit = new QgsGrassEdit ( qGisInterface, qGisInterface->activeLayer (), false ,
415
417
qGisInterface->mainWindow (), Qt::Dialog );
416
418
417
- if ( ed ->isValid () )
419
+ if ( mEdit ->isValid () )
418
420
{
419
- ed ->show ();
421
+ mEdit ->show ();
420
422
mCanvas ->refresh ();
421
- connect ( ed, SIGNAL ( finished () ), this , SLOT ( setEditAction () ) );
422
- }
423
+ connect ( mEdit , SIGNAL ( finished () ), this , SLOT ( setEditAction () ) );
424
+ connect ( mEdit , SIGNAL (finished ()), this , SLOT (cleanUp ()));
425
+ connect ( QgsMapLayerRegistry::instance (), SIGNAL (layerWillBeRemoved (QString)), this , SLOT (closeEdit (QString)));
426
+ }
423
427
else
424
428
{
425
- delete ed;
429
+ delete mEdit ;
430
+ mEdit = NULL ;
426
431
mEditAction ->setEnabled ( true );
427
432
}
428
433
}
@@ -443,6 +448,18 @@ void QgsGrassPlugin::setEditAction()
443
448
}
444
449
}
445
450
451
+ void QgsGrassPlugin::closeEdit (QString layerId)
452
+ {
453
+ if (mEdit ->layer ()->getLayerID () == layerId){
454
+ mEdit ->closeEdit ();
455
+ }
456
+ }
457
+
458
+ void QgsGrassPlugin::cleanUp ()
459
+ {
460
+ disconnect ( QgsMapLayerRegistry::instance (), SIGNAL (layerWillBeRemoved (QString)), this , SLOT (closeEdit (QString)));
461
+ }
462
+
446
463
void QgsGrassPlugin::newVector ()
447
464
{
448
465
// QgsDebugMsg("entered.");
0 commit comments