Skip to content

Commit

Permalink
Fix for #1712.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11185 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso committed Jul 27, 2009
1 parent 47bc7b6 commit 1e53f58
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/plugins/grass/qgsgrassplugin.cpp
Expand Up @@ -35,6 +35,7 @@
#include "qgsrubberband.h"
#include "qgsproject.h"
#include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h"

#include <QAction>
#include <QFileInfo>
Expand All @@ -57,7 +58,7 @@ static const QString pluginVersion = QObject::tr( "Version 0.1" );
* @param theQgisInterFace Pointer to the QGIS interface object
*/
QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
qGisInterface( theQgisInterFace )
qGisInterface( theQgisInterFace ), mEdit(NULL), mTools(NULL)
{
/** Initialize the plugin and set the required attributes */
pluginNameQString = tr( "GrassVector" );
Expand All @@ -68,6 +69,7 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
QgsGrassPlugin::~QgsGrassPlugin()
{
if ( mTools ) mTools->closeTools();
if ( mEdit ) mEdit->closeEdit();
QString err = QgsGrass::closeMapset();
}

Expand Down Expand Up @@ -411,18 +413,21 @@ void QgsGrassPlugin::edit()
}

mEditAction->setEnabled( false );
QgsGrassEdit *ed = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false,
mEdit = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false,
qGisInterface->mainWindow(), Qt::Dialog );

if ( ed->isValid() )
if ( mEdit->isValid() )
{
ed->show();
mEdit->show();
mCanvas->refresh();
connect( ed, SIGNAL( finished() ), this, SLOT( setEditAction() ) );
}
connect( mEdit, SIGNAL( finished() ), this, SLOT( setEditAction() ) );
connect( mEdit, SIGNAL(finished()), this, SLOT(cleanUp()));
connect( QgsMapLayerRegistry::instance(), SIGNAL(layerWillBeRemoved(QString)), this, SLOT(closeEdit(QString)));
}
else
{
delete ed;
delete mEdit;
mEdit = NULL;
mEditAction->setEnabled( true );
}
}
Expand All @@ -443,6 +448,18 @@ void QgsGrassPlugin::setEditAction()
}
}

void QgsGrassPlugin::closeEdit(QString layerId)
{
if(mEdit->layer()->getLayerID() == layerId){
mEdit->closeEdit();
}
}

void QgsGrassPlugin::cleanUp()
{
disconnect( QgsMapLayerRegistry::instance(), SIGNAL(layerWillBeRemoved(QString)), this, SLOT(closeEdit(QString)));
}

void QgsGrassPlugin::newVector()
{
// QgsDebugMsg("entered.");
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/grass/qgsgrassplugin.h
Expand Up @@ -23,6 +23,7 @@
class QgsGrassTools;
class QgsGrassNewMapset;
class QgsGrassRegion;
class QgsGrassEdit;

class QgsMapCanvas;
class QgsRubberBand;
Expand Down Expand Up @@ -118,6 +119,10 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
void saveMapset();
//! Set edit action
void setEditAction();
//! Close the edit if layer is removed
void closeEdit(QString layerId);
//! Cleanup the Grass Edit
void cleanUp();
//! update plugin icons when the app tells us its theme is changed
void setCurrentTheme( QString theThemeName );
private:
Expand Down Expand Up @@ -148,6 +153,7 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
QgsGrassTools *mTools;
//! Pointer to QgsGrassNewMapset
QgsGrassNewMapset *mNewMapset;
QgsGrassEdit *mEdit;

// Actions
QAction *mOpenMapsetAction;
Expand Down

0 comments on commit 1e53f58

Please sign in to comment.