Skip to content
Permalink
Browse files

Fix for #1712.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11185 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso
rugginoso committed Jul 27, 2009
1 parent 8d14394 commit 6e12091aa7bed69530b67d2515bbaed2abea27fa
Showing with 30 additions and 7 deletions.
  1. +24 −7 src/plugins/grass/qgsgrassplugin.cpp
  2. +6 −0 src/plugins/grass/qgsgrassplugin.h
@@ -35,6 +35,7 @@
#include "qgsrubberband.h"
#include "qgsproject.h"
#include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h"

#include <QAction>
#include <QFileInfo>
@@ -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" );
@@ -68,6 +69,7 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
QgsGrassPlugin::~QgsGrassPlugin()
{
if ( mTools ) mTools->closeTools();
if ( mEdit ) mEdit->closeEdit();
QString err = QgsGrass::closeMapset();
}

@@ -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 );
}
}
@@ -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.");
@@ -23,6 +23,7 @@
class QgsGrassTools;
class QgsGrassNewMapset;
class QgsGrassRegion;
class QgsGrassEdit;

class QgsMapCanvas;
class QgsRubberBand;
@@ -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:
@@ -148,6 +153,7 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
QgsGrassTools *mTools;
//! Pointer to QgsGrassNewMapset
QgsGrassNewMapset *mNewMapset;
QgsGrassEdit *mEdit;

// Actions
QAction *mOpenMapsetAction;

0 comments on commit 6e12091

Please sign in to comment.
You can’t perform that action at this time.