[Nepomuk] Segfault on QueryParser

Sebastian Trueg trueg at kde.org
Sun Dec 13 20:19:44 CET 2009

Hi Alessandro,

cross-posting to list since this might be interesting for others, too:

Alessandro Sivieri wrote:
> --------------------------------------
> Code fragment:
> void TagsFacet::emitTerm()
> {
>     QString parsed = merge(d->labels);
>     Query::Query query = Query::QueryParser::parseQuery(parsed);
>     Query::Term term = query.term();
>     emit queryTermChanged(term);
> }
> QString TagsFacet::merge(const QStringList& list) const
> {
>     int i;
>     QString result;
>     for (i = 0; i < list.size(); ++i) {
>         if (i > 0) {
>             result.append(" AND ");
>         }
>         result.append("hastag:");
>         result.append(list[i]);
>     }
>     return result;
> }

this is completely unrelated to the crash but why don't you create
ComparisonTerms directly here? After all you can just do:

  ComparisonTerm( NAO::hasTag(), LiteralTerm( list[i] ) );

And it will result in a query like

  ?r nao:hasTag ?t . ?t rdfs:label ?l . ?l bif:contains "foobar" .

Ok, the crash:

Attached you will find a fix with which the app works very nicely. I
don't know about the crash you mention but the problem with your code is
You use the same Private class name for all the classes. I don't know
the exact result but it is surely not the expected one. MainWindow for
example could end up using the Private class from Tab. When trying to
access a member which is out of the scope of the latter you get a crash.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sembrowser-d-pointer-fix.diff
Url: http://mail.kde.org/pipermail/nepomuk/attachments/20091213/ef9b1ab6/attachment.bat 

More information about the Nepomuk mailing list