[Xapian-devel] setting ValueRangeProcessor at runtime

Peter Karman peter at peknet.com
Sun Nov 15 03:32:20 GMT 2009

I want to set a variable number and type of ValueRangeProcessors at run time
based on a configuration file. But I seem to be running into (what I think is) a
C++ scope issue.

I tried just a simple test to see if I could add 5 VPs in a loop.

    Xapian::QueryParser qparser;
    Xapian::Query query;

    int vp = 0;
    while(vp < 5) {
        Xapian::StringValueRangeProcessor sproc(vp++);

    query = qparser.parse_query(myquery);

That will compile, but when that code executes I get this error:

pure virtual method called
terminate called without an active exception
Abort trap

I *think* what's happening is that the sproc object goes out of scope at the end
of the while() loop and is GC'd by the time the qparser tries to actually parse
the query, so the qparser is trying to access a pointer that has been freed.
But that's just a guess based on my limited knowledge of C++.

What's the correct way to dynamically add a series of ValueRangeProcessors?

Peter Karman  .  http://peknet.com/  .  peter at peknet.com

More information about the Xapian-devel mailing list