Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
repaint layer after commiting
  • Loading branch information
jef-n committed Jan 23, 2012
1 parent 53b6366 commit 32f3690
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/app/qgisapp.cpp
Expand Up @@ -4323,11 +4323,23 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )

if ( !vlayer->isEditable() && !vlayer->isReadOnly() )
{
vlayer->startEditing();
if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities ) )
if ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities == 0 )
{
QMessageBox::information( 0, tr( "Start editing failed" ), tr( "Provider cannot be opened for editing" ) );
res = false;
return false;
}

vlayer->startEditing();

QSettings settings;
QString markerType = settings.value( "/qgis/digitizing/marker_style", "Cross" ).toString();
bool markSelectedOnly = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();

// redraw only if markers will be drawn
if( ( !markSelectedOnly || vlayer->selectedFeatureCount() > 0 ) &&
( markerType == "Cross" || markerType == "SemiTransparentCircle" ) )
{
vlayer->triggerRepaint();
}
}
else if ( vlayer->isModified() )
Expand Down Expand Up @@ -4358,6 +4370,8 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
// and try the commit again later
res = false;
}

vlayer->triggerRepaint();
break;

case QMessageBox::Discard:
Expand All @@ -4366,6 +4380,8 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
QMessageBox::information( 0, tr( "Error" ), tr( "Problems during roll back" ) );
res = false;
}

vlayer->triggerRepaint();
break;

default:
Expand All @@ -4376,24 +4392,14 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
{
vlayer->rollBack();
res = true;
vlayer->triggerRepaint();
}

if ( layer == activeLayer() )
{
activateDeactivateLayerRelatedActions( layer );
}

QSettings settings;
QString markerType = settings.value( "/qgis/digitizing/marker_style", "Cross" ).toString();
bool markSelectedOnly = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();

// repaint only if the there will be/were markers
if (( !markSelectedOnly || vlayer->selectedFeatureCount() > 0 ) &&
( markerType == "Cross" || markerType == "SemiTransparentCircle" ) )
{
vlayer->triggerRepaint();
}

return res;
}

Expand Down

0 comments on commit 32f3690

Please sign in to comment.