Skip to content
Permalink
Browse files

[GRASS] fixed add new layer if vector is not valid

  • Loading branch information
blazek committed Oct 5, 2015
1 parent 0caf944 commit d3f79af3540d61835ca9d8444ca1fad53bb12de6
@@ -588,8 +588,11 @@ void QgsGrassPlugin::onNewLayer( QString uri, QString name )
{
QgsDebugMsg( "uri = " + uri + " name = " + name );
QgsVectorLayer* vectorLayer = qGisInterface->addVectorLayer( uri, name, "grass" );
vectorLayer->startEditing();
qGisInterface->setActiveLayer( vectorLayer );
if ( vectorLayer )
{
vectorLayer->startEditing();
qGisInterface->setActiveLayer( vectorLayer );
}
}

void QgsGrassPlugin::postRender( QPainter *painter )
@@ -336,7 +336,10 @@ void QgsGrassProvider::update()
QgsGrassProvider::~QgsGrassProvider()
{
QgsDebugMsg( "entered" );
mLayer->close();
if ( mLayer )
{
mLayer->close();
}
}


@@ -37,9 +37,10 @@
#include <QTextEdit>

//----------------------- QgsGrassItemActions ------------------------------
QgsGrassItemActions::QgsGrassItemActions( QgsGrassObject grassObject, QObject *parent )
QgsGrassItemActions::QgsGrassItemActions( QgsGrassObject grassObject, bool valid, QObject *parent )
: QObject( parent )
, mGrassObject( grassObject )
, mValid( valid )
{
}

@@ -79,7 +80,8 @@ QList<QAction*> QgsGrassItemActions::actions()
list << deleteAction;
}

if ( mGrassObject.type() == QgsGrassObject::Mapset || mGrassObject.type() == QgsGrassObject::Vector )
if (( mGrassObject.type() == QgsGrassObject::Mapset || mGrassObject.type() == QgsGrassObject::Vector )
&& mValid )
{
// TODO: disable new layer actions on maps currently being edited
QAction* newPointAction = new QAction( tr( "New Point Layer" ), this );
@@ -313,7 +315,7 @@ QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString dirPath
QString gisdbase = dir.path();

mGrassObject = QgsGrassObject( gisdbase, mName, "", "", QgsGrassObject::Location );
mActions = new QgsGrassItemActions( mGrassObject, this );
mActions = new QgsGrassItemActions( mGrassObject, true, this );

mIconName = "grass_location.png";

@@ -360,7 +362,7 @@ QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QS
QString gisdbase = dir.path();

mGrassObject = QgsGrassObject( gisdbase, location, mName, "", QgsGrassObject::Mapset );
mActions = new QgsGrassItemActions( mGrassObject, this );
mActions = new QgsGrassItemActions( mGrassObject, true, this );

mIconName = "grass_mapset.png";
}
@@ -920,7 +922,7 @@ QgsGrassObjectItem::QgsGrassObjectItem( QgsDataItem* parent, QgsGrassObject gras
, mActions( 0 )
{
setState( Populated ); // no children, to show non expandable in browser
mActions = new QgsGrassItemActions( mGrassObject, this );
mActions = new QgsGrassItemActions( mGrassObject, true, this );
}

bool QgsGrassObjectItem::equal( const QgsDataItem *other )
@@ -946,7 +948,7 @@ QgsGrassVectorItem::QgsGrassVectorItem( QgsDataItem* parent, QgsGrassObject gras
setState( Populated );
setIconName( "/mIconDelete.png" );
}
mActions = new QgsGrassItemActions( mGrassObject, this );
mActions = new QgsGrassItemActions( mGrassObject, mValid, this );

QString watchPath = mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name();
QgsDebugMsg( "add watcher on " + watchPath );
@@ -34,7 +34,7 @@ class QgsGrassItemActions : public QObject
{
Q_OBJECT
public:
QgsGrassItemActions( QgsGrassObject grassObject, QObject *parent );
QgsGrassItemActions( QgsGrassObject grassObject, bool valid, QObject *parent );

QList<QAction*> actions();

@@ -52,6 +52,8 @@ class QgsGrassItemActions : public QObject
QString newVectorMap();
void newLayer( QString type );
QgsGrassObject mGrassObject;
// Grass object is valid
bool mValid;
};

class QgsGrassObjectItemBase
@@ -329,7 +329,10 @@ void QgsGrassVectorMapLayer::close()
{
QgsDebugMsg( "close" );
//removeUser(); // removed by map
mMap->closeLayer( this );
if ( mMap )
{
mMap->closeLayer( this );
}
}

QStringList QgsGrassVectorMapLayer::fieldNames( QgsFields & fields )

0 comments on commit d3f79af

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