https://issues.qgis.org/https://issues.qgis.org/favicon.ico2011-10-24T21:58:18ZQGIS Issue TrackingQGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=260952011-10-24T21:58:18ZNathan Woodrow
<ul><li><strong>Must fix</strong> set to <i>Yes</i></li><li><strong>Subject</strong> changed from <i>Labelling/Field calculator: some expressions evaluate to NULL when they shouldn't</i> to <i>Expression parser: some expressions evaluate to NULL when they shouldn't</i></li><li><strong>Assignee</strong> set to <i>Martin Dobias</i></li></ul><p>I have just changed the title because it's related to the underlying expression parser more then anything else.</p> QGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=262452011-11-02T05:26:48ZMartin Dobiaswonder.sk@gmail.com
<ul><li><strong>Resolution</strong> set to <i>fixed</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Fixed in <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/6996946a85ff0b3888084fc472b603dee8ac6350" title="Fix #4441">699694</a></p> QGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=262522011-11-02T14:50:17ZAlister Hood
<ul></ul><p>I guess I should maybe open a new ticket - there is still be a problem for labelling.</p>
<p>As far as I can tell, the field calculator is working correctly, e.g. I can now fill a field with <code>toint($perimeter)</code>, or <code>regexp_replace( toint($area) ,'(\\\\d+)(\\\\d{3})','\\\\1,\\\\2')</code>, and I can label with fields created that way.</p>
<p>But if I try to use either of those expressions for labelling, the label is shown correctly in the output preview, but no labels are drawn on the map.</p> QGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=262532011-11-02T14:53:08ZAlister Hood
<ul></ul><p>Actually, it seems like the labelling doesn't work with any expression except a field name. e.g. no labels are shown if I use the expression <code>1</code> or <code>1+1</code> or <code>$perimeter</code></p> QGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=262542011-11-02T15:10:19ZNathan Woodrow
<ul></ul><p>I noticed this too. I think I know what might be causing the issue.</p>
<p>My guess is that how I'm using QgsExpression::evaluate() is wrong.</p>
<p>In the widget I use:</p>
<pre><code class="cpp syntaxhl"><span class="CodeRay">QVariant value = exp.evaluate( &feature, mLayer->pendingFields() );
</span></code></pre>
<p>but in the labeling class I use:</p>
<pre><code class="cpp syntaxhl"><span class="CodeRay">QVariant result = exp->evaluate( &f, layer->dataProvider()->fields() );
</span></code></pre>
<p>Will patch it and see if that makes any difference.</p> QGIS Application - Bug report #4441: Expression parser: some expressions evaluate to NULL when they shouldn'thttps://issues.qgis.org/issues/4441?journal_id=262642011-11-04T02:47:51ZNathan Woodrow
<ul></ul><p>Opened a new ticket at <a class="issue tracker-1 status-5 priority-4 priority- closed" href="https://issues.qgis.org/issues/4495" title="Expression labels fail to show expressions with no field (Closed)">#4495</a> and supplied a patch.</p>