Skip to content
Permalink
Browse files

Fix seg fault with using empty expression labels, added checks for em…

…pty expression
  • Loading branch information
NathanW2 committed Jun 18, 2011
1 parent 027efca commit 6610187085478bcb8fd07f3e3d04f8f319b5f138
Showing with 10 additions and 5 deletions.
  1. +8 −5 src/app/qgslabelinggui.cpp
  2. +2 −0 src/core/qgspallabeling.cpp
@@ -74,7 +74,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
populateFieldNames();

//Add the current expression to the bottom of the list.
if (lyr.isExpression)
if (lyr.isExpression and !lyr.fieldName.isEmpty())
cboFieldName->addItem(lyr.fieldName);
populateDataDefinedCombos( lyr );

@@ -190,7 +190,6 @@ QgsLabelingGui::~QgsLabelingGui()
void QgsLabelingGui::apply()
{
QgsPalLayerSettings settings = layerSettings();
// If we get here we are good to go.
settings.writeToLayer( mLayer );
// trigger refresh
if ( mMapCanvas )
@@ -205,7 +204,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.fieldName = cboFieldName->currentText();
// Check if we are an expression. Also treats expressions with just a column name as non expressions,
// this saves time later so we don't have to parse the expression tree.
lyr.isExpression = mLayer->fieldNameIndex( lyr.fieldName ) == -1;
lyr.isExpression = mLayer->fieldNameIndex( lyr.fieldName ) == -1 && !lyr.fieldName.isEmpty();

lyr.dist = 0;
lyr.placementFlags = 0;
@@ -484,8 +483,12 @@ void QgsLabelingGui::showExpressionDialog()
return;
}

cboFieldName->addItem(expression);
cboFieldName->setCurrentIndex(cboFieldName->count() - 1);
// Only add the expression if the user has entered some text.
if (!expression.isEmpty())
{
cboFieldName->addItem(expression);
cboFieldName->setCurrentIndex(cboFieldName->count() - 1);
}
}
}

@@ -727,6 +727,8 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
int fldIndex ;
if(lyrTmp.isExpression)
{
if (lyrTmp.fieldName.isEmpty())
return 0;
QgsSearchString searchString;
searchString.setString( lyrTmp.fieldName );
searchString.tree()->referencedColumns();

0 comments on commit 6610187

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