Skip to content

Commit

Permalink
Fix show/hide labels tool with postgres (followup 0232819)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 3, 2016
1 parent ccebd83 commit 98e9ae1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/qgsmaptoolshowhidelabels.cpp
Expand Up @@ -288,21 +288,25 @@ bool QgsMapToolShowHideLabels::showHide( QgsVectorLayer *vl, const bool show )
return false;
}

// we need to pass int value to the provider
// (committing bool value would fail on int field)
int curVal = show ? 1 : 0;

// check if attribute value is already the same
if ( showSuccess && ( showVal != 0 ) == show )
if ( showSuccess && showVal == curVal )
{
return false;
}

// allow NULL (maybe default) value to stand for show label (i.e. 1)
// skip NULL attributes if trying to show label
if ( !showSuccess && show == 1 )
if ( !showSuccess && curVal == 1 )
{
return false;
}

// different attribute value, edit table
if ( ! vl->changeAttributeValue( mCurrentLabel.pos.featureId, showCol, show ) )
if ( ! vl->changeAttributeValue( mCurrentLabel.pos.featureId, showCol, curVal ) )
{
QgsDebugMsg( "Failed write to attribute table" );
return false;
Expand Down

1 comment on commit 98e9ae1

@3nids
Copy link
Member

@3nids 3nids commented on 98e9ae1 May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !!!

Please sign in to comment.