forked from organicmaps/organicmaps
[search] Copy index in query. Fixes crashes. Still TODO to stop the search when another query comes.
This commit is contained in:
parent
8318ed200c
commit
3bac5521d8
3 changed files with 26 additions and 2 deletions
|
@ -79,6 +79,19 @@ template <class IndexT> class MultiIndexAdapter
|
|||
public:
|
||||
typedef typename IndexT::Query Query;
|
||||
|
||||
MultiIndexAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
MultiIndexAdapter(MultiIndexAdapter const & index) : m_indexes(index.m_indexes.size())
|
||||
{
|
||||
for (size_t i = 0; i < index.m_indexes.size(); ++i)
|
||||
{
|
||||
CHECK(index.m_indexes[i], ());
|
||||
m_indexes[i] = index.m_indexes[i]->Clone();
|
||||
}
|
||||
}
|
||||
|
||||
~MultiIndexAdapter()
|
||||
{
|
||||
Clean();
|
||||
|
@ -282,6 +295,16 @@ private:
|
|||
INDEX_REMOVE = 2
|
||||
};
|
||||
|
||||
IndexProxy * Clone() const
|
||||
{
|
||||
IndexProxy * pRes = new IndexProxy(*this);
|
||||
pRes->m_action = INDEX_DO_NOTHING;
|
||||
pRes->m_pIndex = NULL;
|
||||
pRes->m_lockCount = 0;
|
||||
pRes->m_queriesSkipped = 0;
|
||||
return pRes;
|
||||
}
|
||||
|
||||
volatile IndexAction m_action;
|
||||
|
||||
private:
|
||||
|
|
|
@ -90,7 +90,7 @@ struct FeatureProcessor
|
|||
} // unnamed namespace
|
||||
|
||||
Query::Query(string const & query, m2::RectD const & viewport, IndexType const * pIndex)
|
||||
: m_queryText(query), m_viewport(viewport), m_pIndex(pIndex), m_bTerminate(false)
|
||||
: m_queryText(query), m_viewport(viewport), m_pIndex(new IndexType(*pIndex)), m_bTerminate(false)
|
||||
{
|
||||
search::Delimiters delims;
|
||||
SplitAndNormalizeAndSimplifyString(query, MakeBackInsertFunctor(m_keywords), delims);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "../base/string_utils.hpp"
|
||||
#include "../std/function.hpp"
|
||||
#include "../std/queue.hpp"
|
||||
#include "../std/scoped_ptr.hpp"
|
||||
#include "../std/string.hpp"
|
||||
#include "../std/vector.hpp"
|
||||
|
||||
|
@ -46,7 +47,7 @@ private:
|
|||
vector<strings::UniString> m_keywords;
|
||||
strings::UniString m_prefix;
|
||||
|
||||
IndexType const * m_pIndex;
|
||||
scoped_ptr<IndexType const> m_pIndex;
|
||||
IndexType::Query m_indexQuery;
|
||||
|
||||
priority_queue<IntermediateResult> m_results;
|
||||
|
|
Loading…
Add table
Reference in a new issue