Skip to content

Commit

Permalink
[GRASS] disable multiple vector editing on Linux/Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Oct 22, 2015
1 parent ca70491 commit e8cb8c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/providers/grass/qgsgrassprovider.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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() ) )
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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" );
}

Expand Down
3 changes: 3 additions & 0 deletions src/providers/grass/qgsgrassprovider.h
Expand Up @@ -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;
};
Expand Down

0 comments on commit e8cb8c1

Please sign in to comment.