Skip to content
Permalink
Browse files

[GRASS] disable multiple vector editing on Linux/Mac

  • Loading branch information
blazek committed Oct 22, 2015
1 parent ca70491 commit e8cb8c1a99b5075669241bd8290144210e6984c2
Showing with 15 additions and 0 deletions.
  1. +12 −0 src/providers/grass/qgsgrassprovider.cpp
  2. +3 −0 src/providers/grass/qgsgrassprovider.h
@@ -103,6 +103,7 @@ Vect_delete_line_function_type *Vect_delete_line_function_pointer = ( Vect_delet
static QString GRASS_KEY = "grass";

int QgsGrassProvider::LAST_TYPE = -9999;
int QgsGrassProvider::mEditedCount = 0;

QgsGrassProvider::QgsGrassProvider( QString uri )
: QgsVectorDataProvider( uri )
@@ -291,6 +292,14 @@ QgsGrassProvider::~QgsGrassProvider()

int QgsGrassProvider::capabilities() const
{
// Because of bug in GRASS https://trac.osgeo.org/grass/ticket/2775 it is not possible
// close db drivers in random order on Unix and probably Mac -> disable editing if another layer is edited
#ifndef Q_OS_WIN
if ( mEditedCount > 0 && !mEditBuffer )
{
return 0;
}
#endif
// for now, only one map may be edited at time
if ( mEditBuffer || ( mLayer && mLayer->map() && !mLayer->map()->isEdited() ) )
{
@@ -644,6 +653,7 @@ bool QgsGrassProvider::closeEdit( bool newMap, QgsVectorLayer *vectorLayer )
}
connect( mLayer->map(), SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
emit fullExtentCalculated();
mEditedCount--;
return true;
}
return false;
@@ -1129,6 +1139,8 @@ void QgsGrassProvider::startEditing( QgsVectorLayer *vectorLayer )
vectorLayer->setFieldEditable( mLayer->keyColumn(), false );
vectorLayer->setFieldEditable( mLayer->fields().size() - 1, false );

mEditedCount++;

QgsDebugMsg( "edit started" );
}

@@ -481,6 +481,9 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
// last geometry GV_* type, used e.g. for splitting features
int mLastType;

// number of currently being edited providers
static int mEditedCount;

friend class QgsGrassFeatureSource;
friend class QgsGrassFeatureIterator;
};

0 comments on commit e8cb8c1

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