Skip to content

Commit 1e53f58

Browse files
author
rugginoso
committed
Fix for #1712.
git-svn-id: http://svn.osgeo.org/qgis/trunk@11185 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 47bc7b6 commit 1e53f58

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/plugins/grass/qgsgrassplugin.cpp

+24-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "qgsrubberband.h"
3636
#include "qgsproject.h"
3737
#include "qgsvectorlayer.h"
38+
#include "qgsmaplayerregistry.h"
3839

3940
#include <QAction>
4041
#include <QFileInfo>
@@ -57,7 +58,7 @@ static const QString pluginVersion = QObject::tr( "Version 0.1" );
5758
* @param theQgisInterFace Pointer to the QGIS interface object
5859
*/
5960
QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
60-
qGisInterface( theQgisInterFace )
61+
qGisInterface( theQgisInterFace ), mEdit(NULL), mTools(NULL)
6162
{
6263
/** Initialize the plugin and set the required attributes */
6364
pluginNameQString = tr( "GrassVector" );
@@ -68,6 +69,7 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
6869
QgsGrassPlugin::~QgsGrassPlugin()
6970
{
7071
if ( mTools ) mTools->closeTools();
72+
if ( mEdit ) mEdit->closeEdit();
7173
QString err = QgsGrass::closeMapset();
7274
}
7375

@@ -411,18 +413,21 @@ void QgsGrassPlugin::edit()
411413
}
412414

413415
mEditAction->setEnabled( false );
414-
QgsGrassEdit *ed = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false,
416+
mEdit = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false,
415417
qGisInterface->mainWindow(), Qt::Dialog );
416418

417-
if ( ed->isValid() )
419+
if ( mEdit->isValid() )
418420
{
419-
ed->show();
421+
mEdit->show();
420422
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+
}
423427
else
424428
{
425-
delete ed;
429+
delete mEdit;
430+
mEdit = NULL;
426431
mEditAction->setEnabled( true );
427432
}
428433
}
@@ -443,6 +448,18 @@ void QgsGrassPlugin::setEditAction()
443448
}
444449
}
445450

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+
446463
void QgsGrassPlugin::newVector()
447464
{
448465
// QgsDebugMsg("entered.");

src/plugins/grass/qgsgrassplugin.h

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class QgsGrassTools;
2424
class QgsGrassNewMapset;
2525
class QgsGrassRegion;
26+
class QgsGrassEdit;
2627

2728
class QgsMapCanvas;
2829
class QgsRubberBand;
@@ -118,6 +119,10 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
118119
void saveMapset();
119120
//! Set edit action
120121
void setEditAction();
122+
//! Close the edit if layer is removed
123+
void closeEdit(QString layerId);
124+
//! Cleanup the Grass Edit
125+
void cleanUp();
121126
//! update plugin icons when the app tells us its theme is changed
122127
void setCurrentTheme( QString theThemeName );
123128
private:
@@ -148,6 +153,7 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
148153
QgsGrassTools *mTools;
149154
//! Pointer to QgsGrassNewMapset
150155
QgsGrassNewMapset *mNewMapset;
156+
QgsGrassEdit *mEdit;
151157

152158
// Actions
153159
QAction *mOpenMapsetAction;

0 commit comments

Comments
 (0)